>>a = [0, pi, pi/4, pi/8, pi, 3/(pi*2)]
>>b = cos(a);
>>x = linspace(0,pi,40)';
>>y1 = interp1(a,b,x,'nearest');
>>y2 = interp1(a,b,x,'linear');
>>y3 = interp1(a,b,x,'spline');
>>y4 = interp1(a,b,x,'pchip');
如何在同一图表上绘制插值的四条曲线,包括a,b和余弦曲线。我不断得到插值具有不同长度的错误。