Why wont interpolation work

4 views (last 30 days)
James Jeffs
James Jeffs on 30 Sep 2015
Edited: Walter Roberson on 30 Sep 2015
Im trying to interpolate some data with interp1 which looks like
10000 0.002078592
7943.282 0.001956255
6309.573 0.001852454
and so on. however later on there nans, which I have replace with zeros. Im continously getting the message 'The grid vectors are not strictly monotonic increasing.' This is the code im looking to fix
a=xlsread('EIS_data/DK40AH_25degC.xlsx');
b=xlsread('EIS_data/DK40AH_-5degC.xlsx');
c=xlsread('EIS_data/DK40AH_-10degC.xlsx');
d=xlsread('EIS_data/DK40AH_-20degC.xlsx');
%Replace nans
ix = isnan(a);
a(find(ix)) = 0;
ix = isnan(b);
b(find(ix)) = 0;
ix = isnan(c);
c(find(ix)) = 0;
ix = isnan(d);
d(find(ix)) = 0;
a1 = a(:,1);
a2 = a(:,2);
interp1q(a1,a2,frq)
any help would be appreciated.
Thanks
James

Answers (1)

Jan
Jan on 30 Sep 2015
Edited: Jan on 30 Sep 2015
The error message tells you, that the first input of interp1 must be strictly monotonic increaing. When you insert some zeros in between, this is not the case.
What about removing the NaNs?
ix = isnan(a);
a(ix) = []; % Faster without FIND
etc.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!