将下列数据拟合成方程x=20,30,40,50,60,70,80,90,100,110,120y=0,0,43,143,303,497,650,805,913,1000,1075
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 05:27:34
将下列数据拟合成方程x=20,30,40,50,60,70,80,90,100,110,120y=0,0,43,143,303,497,650,805,913,1000,1075
将下列数据拟合成方程
x=20,30,40,50,60,70,80,90,100,110,120
y=0,0,43,143,303,497,650,805,913,1000,1075
将下列数据拟合成方程x=20,30,40,50,60,70,80,90,100,110,120y=0,0,43,143,303,497,650,805,913,1000,1075
这是matlab的命令跟运行结果:
clc
clear
close all
x1=[20,30,40,50,60,70,80,90,100,110,120];
y1=[0,0,43,143,303,497,650,805,913,1000,1075];
plot(x1,y1,'bo')
hold
p=polyfit(x1,y1,3);
p1=num2str(p(1));p2=num2str(p(2));p3=num2str(p(3));p4=num2str(p(4));
x=linspace(20,120,1000);
y=p(1).*x.^3+p(2).*x.^2+p(3).*x+p(4);
plot(x,y,'r')
xlabel('x [20,120]')
s1='y=',s2='x^3+',s3='x^2+',s4='x+';
s=strcat(s1,p1,s2,p2,s3,p3,s4,p4);
ylabel(s)
legend('原始数据','拟合曲线',2);
T=strcat('拟合结果:',s);
title(T,'FontSize',12)
hold off
运行结果如图所示:
分数太少了吧,这么大个题目.