Hello,
I am trying to simplify a symbolic expression, in terms of others,for example:
syms w L C;
Z = 1j*w*L + 1/(1j*w*C)
Ok, the result is (-w^2LC + 1)/(1jwC)
The question is, for example, if I want to simplify the result so that Matlab substitutes -w^2LC+1 for a variable like 'RF1', what should I do?
The simulation I am running outputs several (more than 100) combination from a complex ckt topology, many or all the combinations results could be simplified to Freq1, IntrisicImpedance, etc.
All the Best.
Ronaldo

 채택된 답변

Walter Roberson
Walter Roberson 2016년 4월 20일

1 개 추천

댓글 수: 6

Ronaldo Junior
Ronaldo Junior 2016년 4월 20일
Thanks a lot.
But it doesn't work. Matlab chooses the subexpression automatically.
All the Best
Ronaldo Junior
Ronaldo Junior 2016년 4월 20일
I read the documentation on subs, looks like it does the job. Gonna try.
Ronaldo Junior
Ronaldo Junior 2016년 4월 21일
subs isnt working too.
I keep using it and it simply does not substitute and sometime old variables that I have even cleared reappears...
Any time you use a symbolic variable in an expression, it is evaluated. If it evaluates to itself, then that meaning of it is "captured"; if it evaluates to a previously assigned expression then the expression is substituted including the "capturedness" of any names it might have included. In other words if you assign to a symbolic variable after you have used it in an expression, then the changed meaning only applies to its use in new expressions after that point.
syms a b c
c = a + b %"captures" the association of "a" with the symbol "a"
a = 7; %_new_ references to "a" will use 7
c %is still a + b not 7 + b
subs(c,sym('a'), a)
%the numeric a of 7 will be dropped in, making it the same as
subs(c, sym('a'), 7)
Then the symbol "a" will be found within c and the numeric substitution will be done
Ronaldo Junior
Ronaldo Junior 2016년 4월 21일
Thanks a lot!
May I ask something else? Is there anyway to find recurrent terms within the expression coefficients beyond the subexpr?
All the best!
I am not sure but I think you might be asking about how to find common sub-expressions. That is a bit tricky because the symbolic engine is allowed to reorder expressions. You can work at it using op(), which does not have an interface at the MATLAB level.
Often the easiest approach is to take something like A*B*C and group it as G by using
subs(expression, A, G/(B*C))

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by