ans = 
Solving linear system of equations
Mostrar comentarios más antiguos
I want to solve a system of three equations. I'm using this code to calculate the eigenvectors and eigenvalues, then write the equations for S1, S2 and S3:
%Parâmetros
x=0;
del=0;
al1=0.707;
oc=0.3;
Gamma1=1;
Gamma3=1;
g1=1/100;
%Matriz a ser diagonalizada
sig23e = [-(1i*(del+x)+Gamma1+g1) 1i*al1*oc 0 ];
sig13e = [1i*al1*oc -(1i*x+g1/2) -1i*oc ];
sig14e = [0 -1i*oc 1i*(del-x)-Gamma1/2-g1/2];
A = [sig23e; sig13e; sig14e];
[V,D] = eig(A);
%Solução final
syms A1 A2 A3 sig13
S1 = V(:,1)*exp(D(1,1))
S2 = V(:,2)*exp(D(2,2))
S3 = V(:,3)*exp(D(3,3))
S = [S1,S2,S3];
eqn1 = S(1,:) == 0;
eqn2 = S(2,:) == 0;
eqn3 = S(3,:) == sig13;
sol = solve([eqn1,eqn2,eqn3],[A1,A2,A3])
The problem arises when calculating S1, S2, and S3, if I let them in the format above, the output are something like this:
S1 =
0.3700 - 0.0000i
-0.0000 - 0.0677i
0.0436 + 0.0000i
Which is fine. But when I do the following change to the last part to add the variables A1, A2 and A3:
syms A1 A2 A3 sig13
S1 = A1*V(:,1)*exp(D(1,1))
S2 = A2*V(:,2)*exp(D(2,2))
S3 = A3*V(:,3)*exp(D(3,3))
S = [S1,S2,S3];
eqn1 = S(1,:) == 0;
eqn2 = S(2,:) == 0;
eqn3 = S(3,:) == sig13;
sol = solve([eqn1,eqn2,eqn3],[A1,A2,A3])
The output becomes horrid and the solution using "sol.A1" gives me "Empty sym: 0-by-1"
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 15 de Ag. de 2025
Movida: Walter Roberson
el 15 de Ag. de 2025
format long g
%Parâmetros
x=0;
del=0;
al1=0.707;
oc=0.3;
Gamma1=1;
Gamma3=1;
g1=1/100;
%Matriz a ser diagonalizada
sig23e = [-(1i*(del+x)+Gamma1+g1) 1i*al1*oc 0 ];
sig13e = [1i*al1*oc -(1i*x+g1/2) -1i*oc ];
sig14e = [0 -1i*oc 1i*(del-x)-Gamma1/2-g1/2];
A = [sig23e; sig13e; sig14e];
[V,D] = eig(A);
%Solução final
syms A1 A2 A3 sig13
S1 = V(:,1)*exp(D(1,1))
S2 = V(:,2)*exp(D(2,2))
S3 = V(:,3)*exp(D(3,3))
S1, S2, and S3 are each 3 x 1 vectors.
S = [S1,S2,S3];
So S is a 3 x 3 vector
eqn1 = S(1,:) == 0;
eqn2 = S(2,:) == 0;
eqn3 = S(3,:) == sig13;
eqn1, eqn2, eqn3 are each 1 x 3 equations.
eqn1 and eq2 consists of comparing a set of 3 constants to 0. Unless the constants happen to be exactly 0, solve() involving eqn1 or eqn2 will not have a solution.
sol = solve([eqn1,eqn2,eqn3],[A1,A2,A3])
[eqn1, eqn2, eqn3] is a 3 x 3 set of equations.
You are trying to solve() a 3 x 3 set of equations with respect to exactly 3 variables. The system is overdetermined and does not happen to have a solution.
symvar([eqn1, eqn2, eqn3])
The equations do not have any A1, A2, or A3 at all.
Categorías
Más información sobre Linear Algebra en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
