![](/img/trans.png)
[英]Matlab finding natural frequency, interp1 function creates NaN values
[英]In matlab function interp1- does the order of the new positions, for which the function values are interpolated, matter?
關於matalb函數yi = interp1(x,Y,xi,method)其中x是Y的已知值的位置,xi是新的位置,其Y值需要內插-xi值是否需要排序功能interp1正常工作?
不,查詢點xq
不必排序。
考慮以下示例:
x = 0:pi/4:2*pi;
v = sin(x);
xq_sorted = 0:pi/16:2*pi;
% shuffle the query points randomly
shuffle = randperm(length(xq_sorted));
xq_shuffled=xq_sorted(shuffle);
% interpolate both the sorted and the shuffled query points
vq_sorted = interp1(x,v,xq_sorted);
vq_shuffled = interp1(x,v,xq_shuffled);
% compare results
if any(vq_sorted(shuffle)~=vq_shuffled)
disp('interpolation results do not match');
else
disp('interpolation results match');
end
輸出
interpolation results match
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.