Previous Interpolation based on a condition
Mostrar comentarios más antiguos
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 comentarios
Bob Thompson
el 26 de Feb. de 2019
I'm a little confused what you mean by 'previous interpolation.' How does this differ from regular interpolation?
Also, is your condition literally this?
dt == 20 & rate < 20 & rate > 20
Sam17
el 26 de Feb. de 2019
Bob Thompson
el 26 de Feb. de 2019
So, are you looking for an if statement which contains the interpolation?
if dt == 20 & rate < 20 & rate > 20
ir = interp1(time,rate,r);
end
Also, you cannot actually meet all of those conditions at once. You're asking to identify a rate value which is both greater than 20, and less than 20 at the same time. Are you sure that there isn't supposed to be an or statement in the conditions? Look for rate values which are less than or greater than 20?
Sam17
el 26 de Feb. de 2019
Bob Thompson
el 26 de Feb. de 2019
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.
Respuestas (0)
Categorías
Más información sobre Dates and Time en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!