extract coefficient of symbolic expression

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)

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.

Asked:

on 21 Nov 2011

Community Treasure Hunt

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

Start Hunting!