Interpolating data using two different methods based on the value in the xq matrix.
古いコメントを表示
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
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Interpolation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!