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

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 20 Apr. 2016

1 Stimme

6 Kommentare

Ronaldo Junior
Ronaldo Junior am 20 Apr. 2016
Thanks a lot.
But it doesn't work. Matlab chooses the subexpression automatically.
All the Best
Ronaldo Junior
Ronaldo Junior am 20 Apr. 2016
I read the documentation on subs, looks like it does the job. Gonna try.
Ronaldo Junior
Ronaldo Junior am 21 Apr. 2016
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 am 21 Apr. 2016
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))

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by