From: Steven Lord on

"Cyril " <c.branciard(a)physics.uq.edu.au> wrote in message
news:hmmuuv$irl$1(a)fred.mathworks.com...
> Dear Walter, dear all,
>
> Thanks for your reply.
> The problem with coeffs() is that it does not organize the coefficient it
> returns, so I don't know which coefficient corresponds to which monomial.
> Also, it does not return the null coefficients...
> eg:
>> syms a b X
>> P = a^2*b + a*b*X + 2*a*X + b*X^3;
>> coeffs(P)
> [ 1, 2, 1, 1]
>
> I would need a function that would give me for instance the coefficients
> of P when considered as a polynom in the variable X: sthg like
>> myfunction(P,X)
> [ a^2*b, a*b+2*a, 0, b]
>
> (In Mathematica, this would correspond to the function CoefficientList)
>
> Any idea on how to do that with Matlab ?

Take a look at HELP COEFFS, particularly the _second_ output argument.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ