那位好心人用MATLAB给我计算一下几组数据的一次线性回归系数第一组(1,1.283)(0.6667,1.476)(0.5,1.598)(0.3333,1.770)(0.25,1.908)第二组(1,0.8255)(0.6667,1.0277)(0.5,1.1745)(0.3333,1.3912)(0.25,1.5601)第三组(1,0.943)(0.6667,
来源:学生作业帮助网 编辑:六六作业网 时间:2025/01/05 15:17:45
那位好心人用MATLAB给我计算一下几组数据的一次线性回归系数第一组(1,1.283)(0.6667,1.476)(0.5,1.598)(0.3333,1.770)(0.25,1.908)第二组(1,0.8255)(0.6667,1.0277)(0.5,1.1745)(0.3333,1.3912)(0.25,1.5601)第三组(1,0.943)(0.6667,
那位好心人用MATLAB给我计算一下几组数据的一次线性回归系数
第一组(1,1.283)(0.6667,1.476)(0.5,1.598)(0.3333,1.770)(0.25,1.908)
第二组(1,0.8255)(0.6667,1.0277)(0.5,1.1745)(0.3333,1.3912)(0.25,1.5601)
第三组(1,0.943)(0.6667,1.059)(0.5,1.152)(0.3333,1.266)(0.25,1.364)
第四组(1,0.6642)(0.6667,0.8012)(0.5,0.9098)(0.3333,1.0562)(0.25,1.1773)
第五组(1,0.550)(0.6667,0.642)(0.5,0.710)(0.3333,0.795)(0.25,0.864)
第六组(1,0.4383)(0.6667,1.470.53446)(0.5,0.6076)(0.3333,0.7052)(0.25,0.7823)
第七组(1,0.477)(0.6667,0.528)(0.5,0.592)(0.3333,0.648)(0.25,0.708)
第八组(1,0.39)(0.6667,0.4524)(0.5,0.5186)(0.3333,0.5867)(0.25,0.6519))
能采取这种形式
x=(1 2/3 1/2 1/3 1/4)
y1=(1.283 1.476 1.598 1.770 1.908)
y2=(0.8255 1.0277 1.1745 1.3912 1.5601)
y3=(0.943 1.059 1.152 1.266 1.364)
y4=(0.6642 0.8012 0.9098 1.0562 1.1773)
y5=(0.550 0.642 0.710 0.795 0.864)
y6=(0.4383 0.5344 0.6076 0.7052 0.7823)
y7=(0.477 0.528 0.592 0.648 0.708)
y8=(0.390 0.4524 0.5186 0.5867 0.6519)
问题中第6组数据输错了
那位好心人用MATLAB给我计算一下几组数据的一次线性回归系数第一组(1,1.283)(0.6667,1.476)(0.5,1.598)(0.3333,1.770)(0.25,1.908)第二组(1,0.8255)(0.6667,1.0277)(0.5,1.1745)(0.3333,1.3912)(0.25,1.5601)第三组(1,0.943)(0.6667,
是这样吗?
clc;clear;
x=[1 2/3 1/2 1/3 1/4]
y1=[1.283 1.476 1.598 1.770 1.908];
y2=[0.8255 1.0277 1.1745 1.3912 1.5601];
y3=[0.943 1.059 1.152 1.266 1.364];
y4=[0.6642 0.8012 0.9098 1.0562 1.1773];
y5=[0.550 0.642 0.710 0.795 0.864];
y6=[0.4383 0.5344 0.6076 0.7052 0.7823];
y7=[0.477 0.528 0.592 0.648 0.708];
y8=[0.390 0.4524 0.5186 0.5867 0.6519] ;
Y=[y1;y2;y3;y4;y5;y6;y7;y8]
plot(x,Y,'o-')
for k=1:8
p1(k,:)=polyfit(x,Y(k,:),1);%一次回归系数
p2(k,:)=polyfit(x,Y(k,:),2);%二次回归系数
end
p1,p2
xx=min(x):0.05:max(x);
for m=1:8
Y1(m,:)=polyval(p1(m,:),xx);
Y2(m,:)=polyval(p2(m,:),xx);
end
figure
plot(x,Y,'o',xx,Y1)
figure
plot(x,Y,'o',xx,Y2)
运行结果:
x = 1.0000 0.6667 0.5000 0.3333 0.2500
Y =
1.2830 1.4760 1.5980 1.7700 1.9080
0.8255 1.0277 1.1745 1.3912 1.5601
0.9430 1.0590 1.1520 1.2660 1.3640
0.6642 0.8012 0.9098 1.0562 1.1773
0.5500 0.6420 0.7100 0.7950 0.8640
0.4383 0.5344 0.6076 0.7052 0.7823
0.4770 0.5280 0.5920 0.6480 0.7080
0.3900 0.4524 0.5186 0.5867 0.6519
p1 =
-0.8051 2.0498
-0.9473 1.7168
-0.5434 1.4557
-0.6614 1.2855
-0.4065 0.9358
-0.4452 0.8584
-0.2985 0.7548
-0.3385 0.7061
p2 =
0.6792 -1.6581 2.2652
0.9742 -2.1708 2.0257
0.5261 -1.2041 1.6225
0.6907 -1.5288 1.5045
0.3568 -0.8546 1.0489
0.4309 -0.9863 0.9951
0.3386 -0.7238 0.8622
0.3719 -0.8055 0.8240
还是二次拟合比较好.
太难了,不会呀.