interp1 issue - resampling
10 ビュー (過去 30 日間)
古いコメントを表示
variable1=[24.6944086885135;21.0998152063394;14.7533601994682;6.76823133654033;6.73000233602188;8.34930121372767;29.2864760248330;43.5413625307145;46.7782562150740;48.3839944347439];
auxvariable2=linspace(1.1,156.3,1569);
output=interp1(variable1(1:10,1),auxvariable2);
%
Hi. I got a question about interp1.
I have the data from variable1. I want to create 1569 new points using that data.
I don;t know the function, so I am using interp with 2 parameters.
I am expecting to get 1569 points, but I get 90 points and the rest until 1569 are NaN.
What am I getting wrong?
Thank you!
0 件のコメント
採用された回答
Star Strider
2022 年 11 月 4 日
編集済み: Star Strider
2022 年 11 月 4 日
Try something like this —
variable1=[24.6944086885135;21.0998152063394;14.7533601994682;6.76823133654033;6.73000233602188;8.34930121372767;29.2864760248330;43.5413625307145;46.7782562150740;48.3839944347439];
v1 = 1:numel(variable1);
v2 = linspace(min(v1), max(v1), 1569);
output = interp1(v1, variable1, v2).';
szvariable1 = size(variable1)
szoutput = size(output)
figure
plot(v1, variable1, '.b', 'MarkerSize',10, 'DisplayName','Original')
hold on
plot(v2, output, '.r', 'MarkerSize',0.1, 'DisplayName','Interpolated')
hold off
grid
legend('Location','best')
figure
plot(v1, variable1, '.b', 'MarkerSize',10, 'DisplayName','Original')
hold on
plot(v2, output, '.r', 'MarkerSize',0.5, 'DisplayName','Interpolated')
hold off
grid
legend('Location','best')
xlim([4.75 5.25])
EDIT — (4 Nov 2022 at 16:38)
Added second plot for clarity.
.
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Shifting and Sorting Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

