Error with solve function

2 views (last 30 days)
Maria Sarcos
Maria Sarcos on 23 Oct 2020
Moved: VBBV on 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 Comment
VBBV
VBBV on 18 Jun 2023
Moved: VBBV on 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 = 

Sign in to comment.

Answers (1)

Ameer Hamza
Ameer Hamza on 23 Oct 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 Comments
Ameer Hamza
Ameer Hamza on 23 Oct 2020
What is the error? Which numbers are imaginary?
Maria Sarcos
Maria Sarcos on 23 Oct 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

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!