difficulty solving simulataneous equations
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Brian Tremaine
el 20 de En. de 2024
Comentada: Walter Roberson
el 20 de En. de 2024
I am new to symbolic editor and am having difficulty getting a non-empty solution. As a test I have a problem I can solve by hand yet can't get the editor to generate a non-empty answer,
By hand, my answer is iaD = (1/(La+Lb) ( Vb - Va + Rb*ib - Ra*ia ). I arrive at this answer by 'back substituing' the 2nd two eqations into the first equation. My real problem is a larger network but this problem displays my basic problem.
% rl2.m
% solve simple R, L equations in symbolic editor
% two phases in series
clear all
% variables
% Va, Vb, Ra, Rb, La and Lb are "fixed" inputs
% variable("unknowns") are ia, ib, iaD and ibD
clear syms Ra Rb La Lb Va Vb iaD ibD ia ib
syms Ra Rb La Lb Va Vb iaD ibD ia ib
% check
syms
% equations
clear eqns
eqns = [Lb*ibD - La*iaD + Rb*ib - Ra*ia + Vb == Va, ia == -ib,iaD == -ibD]
% solve
S = solve(eqns, ia, ib)
0 comentarios
Respuesta aceptada
John D'Errico
el 20 de En. de 2024
You have 3 equations, and you calim to have 4 unknowns. However, you only tell solve that you want to solve for TWO unknowns, ia and ib.
syms Ra Rb La Lb Va Vb iaD ibD ia ib
% equations
eqns = [Lb*ibD - La*iaD + Rb*ib - Ra*ia + Vb == Va, ia == -ib,iaD == -ibD]
Solve will require it has the same number of unknowns as equations, and that the equations are independent. So you could do this:
solve(Lb*ibD - La*iaD + Rb*ib - Ra*ia + Vb == Va, ia == -ib,[ia,ib])
Again Count the equations. Count the unknowns. Are they the same? If not, then you have a problem.
2 comentarios
Walter Roberson
el 20 de En. de 2024
clear syms Ra Rb La Lb Va Vb iaD ibD ia ib
Note that clears variables "syms" "Ra" "Rb" and so on -- the "syms" is treated as a variable name.
Note that clearing variables does not reset any symbolic assumptions on the variables.
syms Ra Rb La Lb Va Vb iaD ibD ia ib
That has the effect of effectively clearing any of those names (that already exist) and establishing new symbolic variables with the given names, and resetting any symbolic assumptions on those variables.
... effectively the "clear" statement is redundent (and misleading)
Más respuestas (1)
Torsten
el 20 de En. de 2024
syms Ra Rb La Lb Va Vb iaD ibD ia ib
eqns = [Lb*ibD - La*iaD + Rb*ib - Ra*ia + Vb == Va, iaD == -ibD]
S = solve(eqns, [iaD,ibD])
0 comentarios
Ver también
Categorías
Más información sobre Special Values 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!