フィルターのクリア

confusion regarding interp1 command?

1 回表示 (過去 30 日間)
ABTJ
ABTJ 2020 年 6 月 27 日
コメント済み: Star Strider 2020 年 6 月 28 日
I am trying to watch difference between cubic interpolation and spline interpolation using matlab plot but i am getting same plots in both cases using interp1 command
My code is below. In below code ,if i use spline in place of cubic, i still exactly get same plot,why?
clc
clear all
close all
x = 0:pi/4:2*pi;
v = sin(x);
xq = 0:pi/16:2*pi;
vq2 = interp1(x,v,xq,'cubic');
plot(x,v,'o',xq,vq2,':.');

採用された回答

Star Strider
Star Strider 2020 年 6 月 27 日
The two methods do not produce exactly the same results, however with respect to the amplitude of the values in the plot, they only appear to be the same.
Do this experiment to see how they differ:
x = 0:pi/4:2*pi;
v = sin(x);
xq = 0:pi/16:2*pi;
vq1 = interp1(x,v,xq,'spline');
vq2 = interp1(x,v,xq,'cubic');
plot(x,v,'o',xq,vq2,':.');
difvct = vq1-vq2;
figure
plot(xq, difvct)
grid
.
  2 件のコメント
ABTJ
ABTJ 2020 年 6 月 28 日
so which type of interpolation is better?spline or cubic?
Star Strider
Star Strider 2020 年 6 月 28 日
It likely does not matter. They are almost the same, nowever not actually the same. That was the oint of my post.
I usually use 'pchip' if I want something other than 'linear'.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by