Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
a problem about symbolic polynomial.

Subject: a problem about symbolic polynomial.

From: zedong

Date: 29 Dec, 2008 13:42:02

Message: 1 of 2

I have a polygon:
for example:
syms x y x0 x1 x2 y0 y1 y2
f=-1.0/12.0*x*(3*x*x*x*y2*y2*y0-3*x*x*x*y0*y0*y2-3
*x*x*x*y0*y1*y1+12*y*y*y*x0*x1*x1+12*y*y*y*x0*x0*x
2-12*y*y*y*x0*x0*x1+12*y*y*y*x2*x2*x1-12*y*y*y*x2*
x1*x1-12*y*y*y*x2*x2*x0-3*x*x*x*y2*y2*y1+3*x*x*x*y
2*y1*y1+3*x*x*x*y0*y0*y1+12*x2*x2*y0*x0*y1*y1+12*x
2*y0*y0*x1*x1*y2-12*x2*x2*y0*y0*x1*y1+12*x2*x2*y0*
y0*x1*y-12*x2*y0*y0*x1*x1*y-24*x2*x2*y0*y*y*x1+24*
x2*y0*y*y*x1*x1+12*x2*x2*y0*y*y*x0+12*y2*y2*x0*x0*
y1*x1-12*y2*x0*x0*y1*y1*x2-12*y2*y2*x0*y0*x1*x1+12
*y2*y2*x0*y*x1*x1-24*y2*x0*y*y*x1*x1-12*y2*y2*x0*x
0*y*x1-12*y2*x0*x0*y*y*x2+24*y2*x0*x0*y*y*x1+12*y*
x0*x0*y1*y1*x2-24*x2*x2*y0*x0*y1*y-24*x2*y0*y*x1*x
1*y2+24*x2*x2*y0*y*x1*y1+24*y2*x0*x0*y1*y*x2-24*y2
*x0*x0*y1*y*x1+24*y2*x0*y0*x1*x1*y-24*y*y*x0*x0*y1
*x2+12*y*y*x0*x0*y1*x1-12*y*y*x0*y0*x1*x1-12*y*x2*
x2*x0*y1*y1+24*y*y*x2*x2*x0*y1+12*y*y*x2*x1*x1*y2-
12*y*y*x2*x2*x1*y1+8*x*x*y2*y2*x0*y1+4*x*x*x2*y0*y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*x*y*x0*y0*x1*y2-24*x*y*x2*x0*y
1*y2)


It's very complex.
Can I make it in x y order.

   (for example:
       f=x*y*x0+x*y*x1+x*x*x2+x*x*y2;
     I want to return:
      f=(x0+x1)*xy+(x2+y2)*x^2
      )

Subject: a problem about symbolic polynomial.

From: Alan Weiss

Date: 29 Dec, 2008 19:20:54

Message: 2 of 2

zedong wrote:
> I have a polygon:
> for example:
> syms x y x0 x1 x2 y0 y1 y2
> f=-1.0/12.0*x*(3*x*x*x*y2*y2*y0-3*x*x*x*y0*y0*y2-3
> *x*x*x*y0*y1*y1+12*y*y*y*x0*x1*x1+12*y*y*y*x0*x0*x
> 2-12*y*y*y*x0*x0*x1+12*y*y*y*x2*x2*x1-12*y*y*y*x2*
> x1*x1-12*y*y*y*x2*x2*x0-3*x*x*x*y2*y2*y1+3*x*x*x*y
> 2*y1*y1+3*x*x*x*y0*y0*y1+12*x2*x2*y0*x0*y1*y1+12*x
> 2*y0*y0*x1*x1*y2-12*x2*x2*y0*y0*x1*y1+12*x2*x2*y0*
> y0*x1*y-12*x2*y0*y0*x1*x1*y-24*x2*x2*y0*y*y*x1+24*
> x2*y0*y*y*x1*x1+12*x2*x2*y0*y*y*x0+12*y2*y2*x0*x0*
> y1*x1-12*y2*x0*x0*y1*y1*x2-12*y2*y2*x0*y0*x1*x1+12
> *y2*y2*x0*y*x1*x1-24*y2*x0*y*y*x1*x1-12*y2*y2*x0*x
> 0*y*x1-12*y2*x0*x0*y*y*x2+24*y2*x0*x0*y*y*x1+12*y*
> x0*x0*y1*y1*x2-24*x2*x2*y0*x0*y1*y-24*x2*y0*y*x1*x
> 1*y2+24*x2*x2*y0*y*x1*y1+24*y2*x0*x0*y1*y*x2-24*y2
> *x0*x0*y1*y*x1+24*y2*x0*y0*x1*x1*y-24*y*y*x0*x0*y1
> *x2+12*y*y*x0*x0*y1*x1-12*y*y*x0*y0*x1*x1-12*y*x2*
> x2*x0*y1*y1+24*y*y*x2*x2*x0*y1+12*y*y*x2*x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y*x0*y0*x1+24*x*x2*y
> 0*y*x1*y2-24*x*x2*y0*y*x1*y1+24*x*x2*y0*y*x0*y1+24
> *x*y2*x0*y*x1*y1-24*x*y*x0*y0*x1*y2-24*x*y*x2*x0*y
> 1*y2)
>
>
> It's very complex.
> Can I make it in x y order.
>
> (for example:
> f=x*y*x0+x*y*x1+x*x*x2+x*x*y2;
> I want to return:
> f=(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

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.

Contact us