필터 지우기
필터 지우기

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