필터 지우기
필터 지우기

1-D interpolation question

조회 수: 2 (최근 30일)
Keny
Keny 2014년 4월 21일
댓글: Walter Roberson 2014년 4월 21일
i have some point and values matrix. [100 ..., 195 ....,300 ...]; and i have another matrix that goes from 50 to 400; if i use interp1 and extrap option, my extrap values are added in the beginning and end of the result.
but i want to put 2 different values in beginning and end.
how can i do that?

채택된 답변

Walter Roberson
Walter Roberson 2014년 4월 21일
Turn off extrap. Let NaN be filled in. Then use find() and isnan() to find the boundaries of the extrapolation, and write the extrapolation constants in as desired.
  댓글 수: 2
Keny
Keny 2014년 4월 21일
if i do that there are some nan values both side. for example i want to put a value "50" in the beginning and "100" in the end. how can i seperate the NaN values in the matrix then put my values?
Walter Roberson
Walter Roberson 2014년 4월 21일
idx = ~isnan(YourVector);
first_boundary = find(idx, 1, 'first');
YourVector(1:first_boundary - 1) = 50;
second_boundary = find(idx, 1, 'last');
YourVector(second_boundary + 1 : end) = 100;

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Keny
Keny 2014년 4월 21일
i managed to solve. thanks everyone.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by