I am using the interp1 function to resample (a,b) to (new_a, new_b).
I get NAN for the values of new_b.
a, b are row matrices.
Some values in b are zero. How to get rid of this? Because of NAN I am unable to generate the correct plot for plot(new_a, new_b, ‘r*)
c = cat(1,a, b);
[s,i] = sort(c(1,:)); #Sort by the 1st row
sort_ab = c(:,i);
sort_a = sort_ab(1,:);
sort_b = sort_ab(2,:);
new_a = min(sort_a):0.001:max(sort_a);
new_b = interp1(a, b, new_a);
From http://www.mathworks.com/help/techdoc/ref/interp1.html:
Note that
'linear'is the default interpolation method.You haven’t provided us with the values of
aandb, but the above sounds the most likely explanation.