How to match matrix dimensions?
Afficher commentaires plus anciens
I am making a silly mistake, I am sure, in matching my matrix dimensions. If anyone can spot what I am doing wrong it would be appreciated.
Here is the code to calculate 6 simultaneous equations with 6 unknown variables:
function F = correlation3;
X = [259, 266, 298, 322, 310, 339, 398];
Y = [64.6, 65.48, 65.28, 65.66, 65.86, 65.83, 65.37];
Z = [-42, -35.8, -24.8, -16, -19.7, -9.5 -1];
X2 = X .* X; %Used to simplify the matrix notation within
X3 = X2 .* X; %the while loop.
Y2 = Y .* Y;
Y3 = Y2 .* Y;
Z2 = Z .* Z;
q = [X3 .* X, X3, X2 .* Y2, X2 .* Y, X3 .* Y, X2;
X3, X2, X .* Y2, Y.* X, X2 .* Y, X;
X2 .* Y2, X .* Y2, Y3 .* Y, Y3, Y3 .* X, Y2;
X2 .* Y, X .* Y, Y3, Y2, X .* Y2, Y;
X3 .* Y, X2 .* Y, Y3 .* X, X .* Y2, X2 .* Y2, Y .* X;
X2, X, Y2, Y, Y .* X, 1];
p = [X2.*Z; X.*Z; Y2.*Z; Y.*Z; Y.*Z; Z2];
A, B, C, D, E, F=q\p
end
The error I am presented with is:
"Error using vertcat Dimensions of matrices being concatenated are not consistent.
Error in correlation3 (line 13) q = [X3 .* X, X3, X2 .* Y2, X2 .* Y, X3 .* Y, X2;"
Thanks
2 commentaires
Jackie
le 23 Juil 2013
Youssef Khmou
le 23 Juil 2013
yes the solution x should be [m,p=1],
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices 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!