Why don't the Inner matrix dimensions agree when adding an extra variable?
显示 更早的评论
I'm using multiple regression to obtain the coefficients from 3 predictor variables (x1, x2, x3, each a [1 x 20] array) and two outcome variables (x and y, each a [1 x 20] array). Using the following code:
X = [ones(length(x1),1) x1' x2' x3'];
B = X\devY';
B(1,:)=[]
J = B';
Z = null(J);
to import the [4 x 2] coefficients into a [2 x 3] Jacobian matrix (J) (removing the constant values) from which the null(J)is used to calculate an output known as the UCM using the following code:
for i = 1:N
UCM(:,i) = (Z'*dev(:,i))*Z;
end
This code works for 3 predictor and 2 output variables. However if I add an extra predictor variable (x4) (a [1 x 20] array) I get the following warning:
Error using ==> mtimes Inner matrix dimensions must agree.
Any help would be appreciated.
4 个评论
Jan
2012-11-22
Please learn how to format code in this forum.
Star Strider
2012-11-22
What sizes are Z and dev?
Tim Bennett
2012-11-22
编辑:Tim Bennett
2012-11-22
Tim Bennett
2012-11-25
编辑:Tim Bennett
2012-11-25
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Operators and Elementary Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!