matrix math problems , error in matrix size
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
tyler hollings
am 22 Okt. 2022
Kommentiert: tyler hollings
am 22 Okt. 2022
i have a rectangular matrix of size 18 by 3 and a column of 18 by 1, when I try to solve for the x matrix (3 by 1) it says I have incorrect sized dimensions to do the math, why? mat lab says the rows should agree and it should allow me to divide them using "/"
xx=[x_e; x_a; x_w];
NU=[lnu_e;lnu_a;lnu_w];
co=xx/NU;
0 Kommentare
Akzeptierte Antwort
Paul
am 22 Okt. 2022
Hard to say without without knowing anything about the data in the question. Based on the wording it should work as follows
A = rand(18,3); % 18 by 3
b = rand(18,1); % 18 by 1
x = A\b % solve for 3 x 1, note use of backslash
The result does not satisfy the matrix equation because there are more equations than unknowns
norm(A*x - b)
0 Kommentare
Weitere Antworten (1)
Walter Roberson
am 22 Okt. 2022
xx = rand(18,3);
NU = rand(18,1);
try
xx/NU
fprintf('/ worked\n');
catch ME
fprintf('well, / did not work\n');
end
try
xx\NU
fprintf('\\ worked\n');
catch ME
fprintf('well, \\ did not work\n');
end
2 Kommentare
Siehe auch
Kategorien
Mehr zu Linear Algebra finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!