matlab描点法 用光滑的线连接

2025-04-05 01:32:25
推荐回答(1个)
回答1:

插值

clear;clc
x=[-4.93 -4.91 -4.78 -3.98 -3.57 -3.28 0.20 0.40 0.61 0.68 0.69 0.70 0.73 0.74];
y=[-10.13 -7.32 -2.58 -0.97 -0.11 -0.02 0.45 0.77 2.33 3.11 4.68 6.78 13.02 16.10];
plot(x,y,'.')
n=length(x);
c=linspace(0,1,n);
k=100;%越大越光滑
cc=linspace(0,1,n+k*(n-1));
xx=interp1(c,x,cc,'pchip');
yy=interp1(c,y,cc,'pchip');
hold on
plot(xx,yy)