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!