如何使用matlab在X上回归Y?

时间:2015-01-15 08:45:49

标签: matlab regression linear-regression

鉴于:

Y=[81  55 80  24 78 52  88 45 50 69 66 45 24 43 38 72  41  48 52  52  66 89];

X=[124 49 181 4  22 152 75 54 43 41 17 22 16 10 63 170 125 15 222 171 97 254];

我想在Y(简单线性回归)上回归X。我试过这段代码:

b= regress(Y,X)

但它给了我这个错误:

??? Error using ==> regress at 65 
The number of rows in Y must equal the number of rows in X.

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

regress期望其输入为向量 转置(.')您的输入应该可以解决问题:

>> b = regress( Y.', X.' )
b =
0.4291