matlab进行线性拟合(X,y):(20,-0.98106); (18,-0.88756); (16,-0.79372); (14,-068870);(12,-0.60286); (10,-0.50582); (8,-0.40675); (6,-0.30274);(4,-0.20746); (2,-0.10720); (0,-0.0034); (-2,0.10462);(-4,0.19790); (-6,0.30170); (-8,0.40362); (-10,0.50
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 01:00:38
matlab进行线性拟合(X,y):(20,-0.98106); (18,-0.88756); (16,-0.79372); (14,-068870);(12,-0.60286); (10,-0.50582); (8,-0.40675); (6,-0.30274);(4,-0.20746); (2,-0.10720); (0,-0.0034); (-2,0.10462);(-4,0.19790); (-6,0.30170); (-8,0.40362); (-10,0.50
matlab进行线性拟合
(X,y):(20,-0.98106); (18,-0.88756); (16,-0.79372); (14,-068870);
(12,-0.60286); (10,-0.50582); (8,-0.40675); (6,-0.30274);
(4,-0.20746); (2,-0.10720); (0,-0.0034); (-2,0.10462);
(-4,0.19790); (-6,0.30170); (-8,0.40362); (-10,0.50412);
(-12,0.60321); (-14,0.70614); (-16,0.80749); (-18,0.91196);
(-20,1.0157);
拟合一条直线y=kx 求出k的值,如何用matlab拟合,公式和步骤是什么?图形如何?
本人没有学过matlab,而这个又很急,
matlab进行线性拟合(X,y):(20,-0.98106); (18,-0.88756); (16,-0.79372); (14,-068870);(12,-0.60286); (10,-0.50582); (8,-0.40675); (6,-0.30274);(4,-0.20746); (2,-0.10720); (0,-0.0034); (-2,0.10462);(-4,0.19790); (-6,0.30170); (-8,0.40362); (-10,0.50
在Matlab里输入:
x=[20,18,16,14,12,10,8,6,4,2,0,-2,-4,-6,-8,-10,-12,-14,-16,-18,-20];
y=[-0.98106,-0.88756,-0.79372,-0.68870,-0.60286,-0.50582,-0.40675,-0.30274,-0.20746,-0.1072,-0.0034,0.10462,0.1979,0.3017,0.40362,0.50412,0.60321,0.70614,0.80749,0.91196,1.0157];
k=x'\y'
yy=k*x;
plot(x,y,x,yy,'r');
得到的结果是:
k =
-0.0501
红线是拟合后的值.
我把你的数据里面的第四个y的值068870改成了0.68870