Empty sym: 0-by-1 for a system of equations

조회 수: 2 (최근 30일)
user3490
user3490 2022년 6월 17일
답변: Divyam 2025년 6월 11일
The following system of equations assumes symbolic variables for all the terms. All the terms are assumed to be known values except for the parameter Iout. The objective is to find the parameter Iout in terms of all the other symbolic terms. The returned solution is shown below. Any feedback is appreciated.
syms Vin Iin Vout Iout Ip Is
syms ZL1 ZC1 ZC2 ZLP ZLS ZC3 ZC4 ZL2
syms w M
Z = [ZL1+ZC1, -ZC1, 0, 0;
-ZC1, ZC1+ZC2+ZLP, -1j*w*M, 0;
0, -1j*w*M, ZLS+ZC3+ZC4, -ZC4;
0, 0, -ZC4, ZC4+ZL2;];
I = [Iin; Ip; Is; Iout;];
V = [Vin; 0; 0; -Vout;];
solve(Z*I==V,Iout)
ans = Empty sym: 0-by-1
  댓글 수: 2
David Goodmanson
David Goodmanson 2022년 6월 17일
Hi RN,
you have four equations, one for each row of z*I = V, and one unknown. So, no solution. If you use
s = solve(Z*I==V,Iout,Iin,Ip,Is)
then Iin, for example, is a linear combination of Vin and Vout, and same for the other three currents. The expression for Iin has 984 characters which is pretty typical for a sym solution.
user3490
user3490 2022년 6월 18일
David,
Thanks for your prompt response!

댓글을 달려면 로그인하십시오.

답변 (1개)

Divyam
Divyam 2025년 6월 11일
MATLAB cannot isolate a single unknown in a system of equations unless it can reduce the system directly in terms of that variable. Since the equation involves a matrix-vector product, it needs to solve all variables first. To do so you just need to solve the whole system using the code below:
sol = solve(Z*I == V, [Iin, Ip, Is, Iout]);
You can also use the "linsolve" function for your use case since it has a better performance when to "solve" for numeric and symbolic linear systems. Here is some sample code to help you with using "linsolve":
vars = [Iin; Ip; Is; Iout];
sol_vec = linsolve(Z, V);
Iout_sol = sol_vec(4);
For more information regarding "linsolve" refer to the following documentation: https://www.mathworks.com/help/matlab/ref/linsolve.html

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by