difficulty solving simulataneous equations
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
John D'Errico
2024년 1월 20일
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
Walter Roberson
2024년 1월 20일
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)
추가 답변 (1개)
Torsten
2024년 1월 20일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Special Values에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!