solve system by converting a matrix to vector

1 次查看(过去 30 天)
how i can solve like this eqation:
Ax=b for x,
where A is 2(n-1)×2(n-1) matrix
and b is 2(n-1)×(n-1)matrix
and x=[u v]' is 2(n-1)×(n-1)matrix where u and v are (n-1)×(n-1) matrices
i tried to ues lsqr but i always got an error. I think that because b should be a vector andon also x should be one variable not two u and v.
so my qusetion is can i convert x and b to be as vector and how?
and if i can convert them then i have to change the size of A and make it larger than what its , i think about adding zeros, but it not works with me

回答(1 个)

Torsten
Torsten 2023-2-16
n = 4;
A = rand(2*(n-1),2*(n-1));
b = rand(2*(n-1),n-1);
x = A\b
x = 6×3
-0.2838 -5.2253 -6.4847 0.3891 3.3280 -7.6502 0.6037 3.2668 5.9517 -2.3993 -9.4441 3.3258 1.5573 4.1153 -0.2843 1.3017 3.6396 0.9060
u = x(1:n-1,:)
u = 3×3
-0.2838 -5.2253 -6.4847 0.3891 3.3280 -7.6502 0.6037 3.2668 5.9517
v = x(n:2*(n-1),:)
v = 3×3
-2.3993 -9.4441 3.3258 1.5573 4.1153 -0.2843 1.3017 3.6396 0.9060

类别

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