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x0+x1)*xy+(x2+y2)*x^2
> )
doc collect
In your example,
g = collect(f,x)
Alan Weiss
MATLAB mathematical toolbox documentation
Tags for this Thread
Everyone's Tags:
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
Tag Activity for This Thread
Tag
Applied By
Date/Time
symbolic polyno...
zedong
29 Dec, 2008 08:45:03
Feed for this Thread
MATLAB Central Terms of Use
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.
Contact us at files@mathworks.com