Help with solve and symbolic equations
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Conor Hars
el 16 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)
solve(i1 * (1/(s*C1) + Rf) == i0*R2, i0)
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
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
Respuesta aceptada
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)
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)
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Equation Solving en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
