Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Matlab: symbolic, expand

Subject: Matlab: symbolic, expand

From: tingxing@gmail.com

Date: 13 May, 2008 06:58:13

Message: 1 of 3

Hello,

Can I "fully" expand an expression using matlab?

for a simple example:
       a = x * x + 2*x + 1
       b = y * y

       a11 = a * b
       b11 = a / b

       f = a11 + b11

How can I expand f to a expression containing only x and y?

Thanks in advance.

Ting

Subject: Re: Matlab: symbolic, expand

From: Steven Lord

Date: 13 May, 2008 13:33:29

Message: 2 of 3


<tingxing@gmail.com> wrote in message
news:ec72399e-7ff2-48a8-9a88-1e287b665ae9@w8g2000prd.googlegroups.com...
> Hello,
>
> Can I "fully" expand an expression using matlab?
>
> for a simple example:
> a = x * x + 2*x + 1
> b = y * y
>
> a11 = a * b
> b11 = a / b
>
> f = a11 + b11
>
> How can I expand f to a expression containing only x and y?
>
> Thanks in advance.
>
> Ting

If you have Symbolic Math Toolbox and have defined x and y to be sym
objects, then f should be "expanded" automatically.

syms x y
a = x * x + 2*x + 1
b = y * y
a11 = a * b
b11 = a / b
f = a11 + b11

*snip intermediate output*

f =

(x^2+2*x+1)*y^2+(x^2+2*x+1)/y^2

 If you want that result to be expanded even further, use EXPAND.

--
Steve Lord
slord@mathworks.com


Subject: Re: Matlab: symbolic, expand

From: tingxing@gmail.com

Date: 13 May, 2008 15:30:01

Message: 3 of 3

Really! Thanks.

I guess my previous failure is the result of some grammar errors
made during defining intermediate expressions.

Ting

>
> If you have Symbolic Math Toolbox and have defined x and y to be sym
> objects, then f should be "expanded" automatically.
>
> syms x y
> a = x * x + 2*x + 1
> b = y * y
> a11 = a * b
> b11 = a / b
> f = a11 + b11
>
> *snip intermediate output*
>
> f =
>
> (x^2+2*x+1)*y^2+(x^2+2*x+1)/y^2
>
> If you want that result to be expanded even further, use EXPAND.
>
> --
> Steve Lord
> sl...@mathworks.com

Tags for this Thread

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.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
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 Disclaimer prior to use.
Related Topics