Previous Interpolation based on a condition

조회 수: 5 (최근 30일)
Sam17
Sam17 2019년 2월 26일
댓글: Bob Thompson 2019년 2월 26일
I have a an array with 2 columns, one is datetime and the next one is values say, rate, I want to use previous interpolation on rate. My condition to do previous interpolation is, when the time is 20 seconds apart and the rate is less than 20, and if rate is greater than 20, I put NaN.
Can you help here?
  댓글 수: 5
Sam17
Sam17 2019년 2월 26일
yes. You can keep that in a different statement. else if rate>20, put all values as Nan
Bob Thompson
Bob Thompson 2019년 2월 26일
Ah, I see how it should read now. Yes, you can add that elseif condition to your if statement.
if dt == 20 & rate < 20
ir = interp1....
elseif rate > 20
ir = nan;
end
What are you going to do though if rate is exactly 20? You may just want to ignore it, just making sure you have considered the possibility.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by