X=[0.2 0.4 0.6 0.8 1.0]; y=[0.98 0.92 0.81 0.64 0.38]; plot(X,y) % X应为大写字母 hold on for i=1:1:5 y(i)=0.98-0.3*(X(i)-0.2)-0.62500*(X(i)-0.2)(X(i)-0.4)-0.20833(X(i)-0.2)(X(i)-0.4)(X(i)-0.6)-0.52083*(X(i)-0.2)(X(i)-0.4)(X(i)-0.6)(X(i)-0.8); % X应为大写字母 end k=[ 0 1 10 11]; x0=0.2+0.08k; y0=zeros(1,4); % 需要先初始化y0 for i=1:1:4 y0(i)=0.98-0.3*(x0(i)-0.2)-0.62500*(x0(i)-0.2)(x0(i)-0.4)-0.20833(x0(i)-0.2)(x0(i)-0.4)(x0(i)-0.6)-0.52083*(x0(i)-0.2)(x0(i)-0.4)(x0(i)-0.6)*(x0(i)-0.8); end plot ( x0,y0, 'o') % 多余的一项x0,y0应删除 hold on y1=spline(X,y,x0); plot (x0,y1, 'o') hold on s=csape(X,y,'variational'); % 右引号应为英文状态下的单引号 fnplt(s,'r') hold on gtext('三次样条自然边界') gtext('原图像') gtext('4次牛顿插值') % 最后一行不需要加入多余的空


原文地址: https://www.cveoy.top/t/topic/fd4a 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录