p7_9.m

来自「Advanced Engineering Mathematics using M」· M 代码 · 共 25 行

M
25
字号
% P7_9.M Compare 6th order polynomial and spline fit%%x=-3:3;y=[0.6 0.2 0.6 3.0 0.6 0.2 0.6];%fprintf(' Coefficients of 6th order polynomial')p=polyfit(x,y,6)xplot=[-4:0.01:4];f=polyval(p,xplot);%clfsubplot(2,1,1),plot(x,y,'o',xplot,f,'-')title('Polynomial fit 6th order')axis([-4 4 -1 3.5])grid %yspline=spline(x,y,xplot);subplot(2,1,2),plot(x,y,'o',xplot,yspline,'-')title('Spline fit ')axis([-4 4 -1 3.5])grid %% Add a few comments to introduce the script and%  explain it

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?