Interpolating data using two different methods based on the value in the xq matrix.
Show older comments
I want to interpolate a set of data using 'nearest' method if the value in the sample data is less than 0.38 and the usual type for all other values. I have coded this as:
f is a 1x5000 matrix with values 0-3.2
normalisedf is a 1x7994 matrix
factors is a 1x7994 matrix
Fmax = 0.38
h=length(f)
for i = 1:h
if f(1,:) < = fmax
newfactors(1,i) = interp1(normalisedf,factors,f,'nearest');
else
newfactors(1,i) = interp1(normalisedf,factors,f)
end
This makes all of the values for when f<0.38 NaN so must be something wrong with my if statement.
Any help would be greatly appreciated
Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!