extract coefficient of symbolic expression
Show older comments
I have a symbolic expression, I need to extract the coefficient of a given combination of trigonometric functions. Something like: A*sin(q1)*(cos(q2) + sin(q3)) I need to extract A. Is there any way to do that?
Thanks, Nick
Answers (1)
Walter Roberson
on 21 Nov 2011
0 votes
There is a way to do it, but it is not nice to deal with. You use MuPAD's indets() along with some nasty type expressions.
Depending on how your expression is structured, it might be much easier to op() the expression as a whole, then select() over the resulting list to pull out things that look like the appropriate sub-expression, then map() op() over the resulting expressions in order to pull out the coefficients.
Categories
Find more on Common Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!