Error with solve function

2 次查看(过去 30 天)
Maria Sarcos
Maria Sarcos 2020-10-23
移动VBBV 2023-6-20
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 个评论
VBBV
VBBV 2023-6-18
移动:VBBV 2023-6-20
@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 = 

请先登录,再进行评论。

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-10-23
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 个评论
Ameer Hamza
Ameer Hamza 2020-10-23
What is the error? Which numbers are imaginary?
Maria Sarcos
Maria Sarcos 2020-10-23
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by