怎么用matlab画线性拟合图x=[ 17.5 17.43 16 14.93 14.04 12.9 13.07 12.4 12.45 13.3 13.92 13.91 14.1 15.63 15.34 15.47 15.9115.91 16.3 15.83 15.7 16.3 16.28 15.34 14.03 12.6 13 12.18 11.57 11.4 11.2];y=[22.71 23.74 23.5 23 23 17 20 19.7 19 20 2
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/23 06:15:58
怎么用matlab画线性拟合图x=[ 17.5 17.43 16 14.93 14.04 12.9 13.07 12.4 12.45 13.3 13.92 13.91 14.1 15.63 15.34 15.47 15.9115.91 16.3 15.83 15.7 16.3 16.28 15.34 14.03 12.6 13 12.18 11.57 11.4 11.2];y=[22.71 23.74 23.5 23 23 17 20 19.7 19 20 2
怎么用matlab画线性拟合图
x=[ 17.5 17.43 16 14.93 14.04 12.9 13.07 12.4 12.45 13.3 13.92 13.91 14.1 15.63 15.34 15.47 15.9115.91 16.3 15.83 15.7 16.3 16.28 15.34 14.03 12.6 13 12.18 11.57 11.4 11.2];
y=[22.71 23.74 23.5 23 23 17 20 19.7 19 20 21 21.3 22 24 24 24.4 24.1 23.8 23.3 23.5 23.6 24.2 25 25 25 25 24 24 24 15 15];
上面是两组数据,我想问问各位怎么用matlab画出线性拟合图?
最好有仔细的过程,
怎么用matlab画线性拟合图x=[ 17.5 17.43 16 14.93 14.04 12.9 13.07 12.4 12.45 13.3 13.92 13.91 14.1 15.63 15.34 15.47 15.9115.91 16.3 15.83 15.7 16.3 16.28 15.34 14.03 12.6 13 12.18 11.57 11.4 11.2];y=[22.71 23.74 23.5 23 23 17 20 19.7 19 20 2
x=[ 17.5 17.43 16 14.93 14.04 12.9 13.07 12.4 12.45 13.3 13.92 13.91 14.1 15.63 15.34 15.47 15.9115.91 16.3 15.83 15.7 16.3 16.28 15.34 14.03 12.6 13 12.18 11.57 11.4 11.2];
y=[22.71 23.74 23.5 23 23 17 20 19.7 19 20 21 21.3 22 24 24 24.4 24.1 23.8 23.3 23.5 23.6 24.2 25 25 25 25 24 24 24 15 15];
A=polyfit(x,y,2)%2为拟合次数
z=polyval(A,x);
plot(x,y,'k+',x,z,'r') %作出数据点和拟合曲线的图形