matrix math problems , error in matrix size

조회 수: 1 (최근 30일)
tyler hollings
tyler hollings 2022년 10월 22일
댓글: tyler hollings 2022년 10월 22일
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;

채택된 답변

Paul
Paul 2022년 10월 22일
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
x = 3×1
0.5890 0.4314 0.1437
ans = 18×1
-0.1966 -0.0326 0.4505 0.0437 0.3522 -0.0633 -0.0692 -0.6059 -0.3226 -0.0753
The result does not satisfy the matrix equation because there are more equations than unknowns
norm(A*x - b)
See mldivide, \ for more info on how it treats this case.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2022년 10월 22일
xx = rand(18,3);
NU = rand(18,1);
try
xx/NU
fprintf('/ worked\n');
catch ME
fprintf('well, / did not work\n');
end
well, / did not work
try
xx\NU
fprintf('\\ worked\n');
catch ME
fprintf('well, \\ did not work\n');
end
ans = 3×1
0.4033 0.1974 0.1226
\ worked

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by