Why don't the Inner matrix dimensions agree when adding an extra variable?
Ältere Kommentare anzeigen
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 Kommentare
Jan
am 22 Nov. 2012
Please learn how to format code in this forum.
Star Strider
am 22 Nov. 2012
What sizes are Z and dev?
Tim Bennett
am 22 Nov. 2012
Bearbeitet: Tim Bennett
am 22 Nov. 2012
Tim Bennett
am 25 Nov. 2012
Bearbeitet: Tim Bennett
am 25 Nov. 2012
Antworten (0)
Kategorien
Mehr zu Operators and Elementary Operations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!