Empty sym: 0-by-1 for a system of equations
2 ビュー (過去 30 日間)
古いコメントを表示
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)
2 件のコメント
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.
回答 (1 件)
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
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!