Filter löschen
Filter löschen

Error with solve function

2 Ansichten (letzte 30 Tage)
Maria Sarcos
Maria Sarcos am 23 Okt. 2020
Verschoben: VBBV am 20 Jun. 2023
I'm trying to solve these equations and find I1,I2,I3 but when I run it it gives me an error
syms I1 I2 I3
eqn1 = I1*(R_s + X_s) + I3*X_m == V1;
eqn2 = (I2*(X_r + R_r + Z1))/(I3*X_m) == 0;
eqn3 = I1 + I3 - I2 == 0;
S = solve([eqn1,eqn2,eqn3],[I2,I2,I3]);
I1sol = S.I1;
I2sol = S.I2;
I3sol = S.I3;
  1 Kommentar
VBBV
VBBV am 18 Jun. 2023
Verschoben: VBBV am 20 Jun. 2023
@Maria Sarcos, It seems you are using the same variable I2 twice to solve the equations. See @Ameer Hamza answer where he used all three variables
syms I1 I2 I3 R_s X_s X_m V1 X_r R_r Z1
eqn1 = I1.*(R_s + X_s) + I3.*X_m == V1;
eqn2 = (I2.*(X_r + R_r + Z1))./(I3*X_m) == 0;
eqn3 = I1 + I3 - I2 == 0;
% ------------------------->> use I1 in place of I2
S = solve([eqn1,eqn2,eqn3],[I1,I2,I3]);
I1sol = S.I1
I1sol = 
I2sol = S.I2
I2sol = 
0
I3sol = S.I3
I3sol = 

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Ameer Hamza
Ameer Hamza am 23 Okt. 2020
You also need to define other variables as symbolic
syms I1 I2 I3 R_s X_s X_m V1 X_r R_r Z1
eqn1 = I1*(R_s + X_s) + I3*X_m == V1;
eqn2 = (I2*(X_r + R_r + Z1))/(I3*X_m) == 0;
eqn3 = I1 + I3 - I2 == 0;
S = solve([eqn1,eqn2,eqn3],[I1,I2,I3]);
I1sol = S.I1;
I2sol = S.I2;
I3sol = S.I3;
  3 Kommentare
Ameer Hamza
Ameer Hamza am 23 Okt. 2020
What is the error? Which numbers are imaginary?
Maria Sarcos
Maria Sarcos am 23 Okt. 2020
Error using sym.getEqnsVars>checkVariables (line 87)
Second argument must be a vector of symbolic variables.
Error in sym.getEqnsVars (line 54)
checkVariables(vars);
Error in solve>getEqns (line 429)
[eqns, vars] = sym.getEqnsVars(argv{:});
Error in solve (line 226)
[eqns,vars,options] = getEqns(varargin{:});
Error in Elektro (line 35)
S = solve([eqn1,eqn2,eqn3],[I2,I2,I3]);
X_s,X_m,X_r these variables have imaginary numbers

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by