如何在matlab中使用interp1

时间:2013-07-19 20:23:58

标签: matlab

我有数据

x=[14.0716101600000 17.7292101600000    21.3868101600000    21.3868101600000    25.0444101600000    28.7020101600000    32.3596101600000    36.0172101600000    39.6748101600000    43.3324101600000    46.9900101600000    50.6476101600000    54.3052101600000    57.9628101600000    61.6204101600000    65.2780101600000    68.9356101600000    72.5932101600000    76.2508101600000    79.9084101600000    83.5660101600000    87.2236101600000]

y=[0    0   0   0.152400000000000   0.152400000000000   0.533400000000000   0.685800000000000   0.838200000000000   0.990600000000000   1.14300000000000    1.14300000000000    1.14300000000000    1.29540000000000    1.44780000000000    1.60020000000000    1.75260000000000    1.90500000000000    2.05740000000000    2.20980000000000    2.36220000000000    2.51460000000000    2.66700000000000]

new_x=[21.38,25.03,28.70,32.33,35.99,39.55,45.13,48.80,54.38,58.05];

然而,当我使用interp1之类的

new_y = interp1(x,y,new_x);

它没有用。请告诉我原因。非常感谢你!

1 个答案:

答案 0 :(得分:2)

x向量必须严格单调。在您的数据中,x的第三和第四个元素是相等的。如果您从xy移除

中的第四个元素
x(4)=[];
y(4)=[];

它没有问题。