建立模型y=f(x1,x2,x3,x4),因为y是关于x1,x2,x3,x4的线性函数,所以有f(x1,x2,x3,x4)=a0+a1*x1+a2*x2+a3*x3+a4*x4,
x1=[2,3,7,6,5]';x2=[1,5,8,6,7]';x3=[4,7,9,12,10]';
x4=[5,8,10,13,11]';y=[23,28,32,40,35]';
F=[ones(size(y)),x1,x2,x3,x4];
a=F\y; %最小二乘法求得线性参数
F =
1 2 1 4 5
1 3 5 7 8
1 7 8 9 10
1 6 6 12 13
1 5 7 10 11
Warning: Matrix is singular to working precision.
> In multiple1 (line 7)
a =
NaN
NaN
NaN
-Inf
Inf
>> det(F)
ans =
0
得不出线性参数a,矩阵F是奇异的
可能你的数据有问题,我用多项式回归分析试试
还是不行,请大神来回答吧
clc
clear all
x1=[2 3 7 6 5]'
x2=[1 5 8 6 7]'
x3=[4 7 9 12 10]'
x4=[5 8 10 13 11]'
x0=ones(5,1)%常数项
x=[x0 x1 x2 x3 x4]
y=[23 28 32 40 35]'
[b,bint,r,rint,s]=regress(y, x)
rcoplot(r,rint)
b =
0
0.1263
-0.4977
-11.1635
13.5618