标签:matlab 列存储 分代 根据 plot sub tla 构造 代码
MATLAB实验
部分代码
x=[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1];
y=[-0.447,1.978,3.28,6.16,7.08,7.34,7.66,9.56,9.48,9.30,11.2];
for n=1:9
f=polyfit(x,y,n);
for i=1:n+1 %answer矩阵存储每次求得的方程系数,按列存储
answer(i,n)=f(i);
end
x0=0:0.01:1;
y0=f(1)*x0.^n ;%根据求得的系数初始化并构造多项式方程
for num=2:1:n+1
y0=y0+f(num)*x0.^(n+1-num);
end
subplot(3,3,n)
plot(x,y,‘*‘)
hold on
plot(x0,y0)
end
suptitle
标签:matlab 列存储 分代 根据 plot sub tla 构造 代码
原文地址:https://www.cnblogs.com/zy2481912102/p/14883149.html