Solve Linear Equation with Constraints on Variables
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
THOMAS DEGAETANO
am 10 Sep. 2023
Kommentiert: Dyuman Joshi
am 15 Sep. 2023
I am trying to solve a system of linear equations with the following expressions:
A*B1 = C; where:
syms L1 L2 L3 m1 m2 m3 n1 n2 n3
A = [-1, 1, 1; 1,-4,2; 1, 2,-4]
B1 = [L1; m1; n1]
C = [0;0;0]
with the constraint that: L1^2 + m1^2 + n1^2 == 1. I keep getting an error with linsolve to solve the variables L1, m1, and n1.
Any help would be greatly appreacted!
0 Kommentare
Akzeptierte Antwort
Matt J
am 10 Sep. 2023
Bearbeitet: Matt J
am 10 Sep. 2023
You can use trustregprob from this FEX download,
to obtain a numerical least squares solution.
A = [-1, 1, 1; 1,-4,2; 1, 2,-4]
C = [0;0;0];
B1=trustregprob(A.'*A,A.'*C,1)
Weitere Antworten (1)
Dyuman Joshi
am 10 Sep. 2023
syms L1 L2 L3 m1 m2 m3 n1 n2 n3
A = [-1, 1, 1; 1,-4,2; 1, 2,-4];
B1 = [L1; m1; n1];
C = [0;0;0];
%Equations to be solved
eqn1 = A*B1 == C;
eqn2 = L1^2+m1^2+n1^2 == 1;
[L,m,n] = solve([eqn1; eqn2], [L1,m1,n1])
15 Kommentare
Dyuman Joshi
am 15 Sep. 2023
"i honestly didnt understand what a full rank matrix was"
If you are going to work and write code in MATLAB, I strongly recommend you understand the basics of Matrix algebra, because MATLAB is literally based on it.
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!














