solve system by converting a matrix to vector

조회 수: 1 (최근 30일)
Hajar Alshaikh
Hajar Alshaikh 2023년 2월 16일
답변: Torsten 2023년 2월 16일
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