필터 지우기
필터 지우기

interp1 vector of interpolated sample points using Euler method

조회 수: 3 (최근 30일)
NOtway
NOtway 2022년 10월 13일
댓글: Torsten 2022년 10월 13일
Hi, I have sompe tabular data that I have imported and have to interpolate between.
[date, t, Rainfall, Evap, I_t] = readvars("BOM_Data.xlsx");
% Define functions to allow interpolation of data
RAINFALL = @(time) interp1(t,Rainfall,time);
EVAP = @(time) interp1(t,Evap,time);
However when I use these values later on in the code it isnt working and those functions spit out NaN values for the first timestep.
For example, one of those equations is:
P_in(i) = RAINFALL(time(i)) *A_catch * C ;
Where A_catch and C are constant variables. The 2nd and further timesteps seem to work, however the 1st one is NaN, which flows on through to toher calcs and messes up others.
  댓글 수: 1
Torsten
Torsten 2022년 10월 13일
The t array from your Excel data must start with t(1) = 0. Is this the case ?

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

답변 (1개)

Jiri Hajek
Jiri Hajek 2022년 10월 13일
Please have a look into the documentation of interp1, namely the section on extrapolation method. You'll see that NaNs are the default result when you try to extrapolate, which is quite sensible.You have to check your input data and see whether you really want to extrapolate, as this is not really a typical task for an iterpolation method.
  댓글 수: 2
NOtway
NOtway 2022년 10월 13일
I dont need to extrapolate, only interpolate (eg. take my daily data and use it for hourly Euler timesteps). Do you have any suggestions on more suitable methods to go about this then?
Jiri Hajek
Jiri Hajek 2022년 10월 13일
Perhaps you dont need it or want it, but it is the most straightforward explanation for the NaNs you are geting. You have to carefully check the inputs into the interpolator, that is all. You see, we do not know what are the values in your variables,you have to check them yourself...

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

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by