func14.m
来自「数值分析最常用的四十种算法」· M 代码 · 共 13 行
M
13 行
%func14.m
%polynomial Fitting,the residue analysis willbe show at the end
%曲线拟合均调用了matlab的函数
x=linspace(-1,1,9)
y=[-0.2209,0.3295,0.8826,1.4392,2.0003,2.5645,3.1334,3.8061,4.2836];
[p,S] = polyfit(x,y,3)
f = polyval(p,x);
plot(x,y,'o',x,f,'-')
disp(abs(norm(y,inf)-norm(f,inf)))
%p=-0.03562558922559*x^3+0.04342683982684*x^2+2.29792053872054*x+2.00616103896104
%the residure is (defined by infinite norm on those vector) : 0.0283
%can also see the figure
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?