MATLAB: How to get symbolic subexpressions

expressionsubexpressionsymbolic

Hi
How to get individual subexpressions from symbolic expression if expression is in form of collect output. For example i got following expression from collect():
u1*(2.794181081*u2^2 – 2.3381963*u2^4 + 0.46413*u2 – 0.5202912702) – 2.636996736*u2 + 0.3739*u1^4
The expression contains three terms. I would like to obtain each term individualy. Is there any built in function for such operation?
My only idea is to transform it to char and make syntax analysis.

Best Answer

  • syms u1 u2
    z = vpa(u1*(2.794181081*u2^2 - 2.3381963*u2^4 + 0.46413*u2 - 0.5202912702) - 2.636996736*u2 + 0.3739*u1^4,10);
    [t k]=coeffs(z,u1)
    out = t.*k