Help with solve and symbolic equations

14 visualizaciones (últimos 30 días)
Conor Hars
Conor Hars el 16 de Jun. de 2023
Editada: VBBV el 18 de Jun. de 2023
syms vA vB i1 i0 C1 Rf R2 real
syms s
eqn1 = vA - vB == i1 * (1/(s*C1) + Rf);
eqn2 = vA - vB == i0 * R2;
solve([eqn1;eqn2], i0)
ans = Empty sym: 0-by-1
solve(i1 * (1/(s*C1) + Rf) == i0*R2, i0)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
ans = 
I'm looking to rearrange the equations for i0 in terms of the other unknowns. The second solve works for this, but the first solve fails (returns Empty sym). Can anyone clarify what I'm doing wrong? Thank you
  2 comentarios
VBBV
VBBV el 16 de Jun. de 2023
Editada: VBBV el 18 de Jun. de 2023
In the first approach, the LHS of both equations are same and when you try to solve only for variable i0 using two equations it returns empty due to cyclical redundancy.
syms vA vB i1 i0 C1 Rf R2 real
syms s
eqn1 = vA - vB == i1 * (1/(s*C1) + Rf);
eqn2 = vA - vB == i0 * R2;
sol = vpasolve([(eqn1);(eqn2)], [i0, i1])
sol.i0
sol = vpasolve(i1 * (1/(s*C1) + Rf) == i0*R2, i0)
Use also vpasolve for solving equations
Conor Hars
Conor Hars el 16 de Jun. de 2023
Movida: VBBV el 18 de Jun. de 2023
Thank you!

Iniciar sesión para comentar.

Respuesta aceptada

John D'Errico
John D'Errico el 16 de Jun. de 2023
The first equation does not use i0 at all. So it makes no sense to try to solve two equations for one unknown anyway, where that unknown only appears in one of the equations.
The second solve you did makes sense. You have ONE equation. And ONE unknown. You cannot use solve to solve for TWO equations with one unknown.
syms vA vB i1 i0 C1 Rf R2 real
syms s
eqn1 = vA - vB == i1 * (1/(s*C1) + Rf);
eqn2 = vA - vB == i0 * R2;
We can use solve directly on eqn2.
solve(eqn2,i0)
ans = 
The two equations are tied together, since both have the same left hand side, vA-vB. So you can also do this (I'll use returnconditions this time to let solve tell me when there might be problems in the solution.)
i0sol = solve(eqn2-eqn1,i0,'returnconditions',true)
i0sol = struct with fields:
i0: (i1*(Rf + 1/(C1*s)))/R2 parameters: [1×0 sym] conditions: (in(s, 'real') & C1 ~= 0 | i1 == 0) & R2 ~= 0
where it tells us that there are some issues, so R2 must not be zero, etc.
The difference here is that we have eliminated two of the variables, which could be anything, but also reducing the problem down to one equation to solve.
  1 comentario
Conor Hars
Conor Hars el 16 de Jun. de 2023
Thanks for the response. I've just discovered "eliminate", which is what I had in mind: eliminate([eqn1; eqn2], [vA vB])

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by