Transform an equation to multinominal (Extract of coefficients)

Hello everybody,
I need help with one question. I have this equation:
equ = (Q*s^4 + (omega_0 + 2*Q*omega_alfa)*s^3 + (Q*omega_alfa^2 + 2*omega_0*omega_alfa)*s^2 + (omega_0*omega_alfa^2)*s + Q*omega_0^2*omega_alfa^2*s0_alfa1*s0_alfa2) / (Q*omega_alfa^2 + 2*Q*omega_alfa*s + Q*s^2)
As you can see, there are both, numerator and denominator (two multinominals). And now what I need: I'm looking for some function or something which would transform that equation to only one multinominal. I know it is possible on the paper but in Matlab I am not sure. I have already tried a function 'COLLECT' but this function gives me only the equation above. And I need something in this form:
equ = (something)*s^4 + (something)*s^3 + (something)*s^2 + (something)*s^1 + (something)*s^0
Probably it is because of equ is variable, not zero. Then the "equation" is only expression. (How can I put "equ" equal to zero, do the "collect" function and then put it to variable?)
After that I can do this: [x1,x2] = coeffs(evalin(symengine,['numer(' char(equ) ')']),s);
I know I can use that for numerator (numer) and denominator (denom) but I need those coefficients later in my calculations in form of 'vector'. And if I have two multinominals I can't put them both to one multinominal because of symbolic variables. And no... I can't use subs(). I need it in this symbolic form for later calculations.

Answers (1)

You can only do that if you are prepared for your "something" to involve 1/(s+omega_alfa)^2
Dropping into MuPAD language (because some of these operations are not directly exposed to MATLAB until at least R2012a):
T := factor(equ);
newequ := map(v -> v/denom(T), collect(numer(T),s));
By oversvation you can then see that every s^n term has an irremovable (s+omega_alfa)^2 in its denominator.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Asked:

on 23 May 2012

Community Treasure Hunt

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

Start Hunting!