Why don't the Inner matrix dimensions agree when adding an extra variable?
Afficher commentaires plus anciens
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 commentaires
Jan
le 22 Nov 2012
Please learn how to format code in this forum.
Star Strider
le 22 Nov 2012
What sizes are Z and dev?
Tim Bennett
le 22 Nov 2012
Modifié(e) : Tim Bennett
le 22 Nov 2012
Tim Bennett
le 25 Nov 2012
Modifié(e) : Tim Bennett
le 25 Nov 2012
Réponses (0)
Catégories
En savoir plus sur Operators and Elementary Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!