From: JinKyu on
Hello, there.

I have a problem in using matlab symbolic toolbox.
Here is the question.

Let's imagine that we want to have the abbreviate expression for the complex expression.
For example, the complex expression is shown below.

U=2*(a*x+b*y+2*c*z) + (a*x + 3*b*(y^2))

Here, all the variables (a, x, b, y, c, a) are symbolic.
If symbolic variables such as Uco1 and Uco2 are defined as
Uco1=2*(a*x+b*y+2*c*z) and
Uco2=(a*x + 3*b*(y^2)), the U can be expressed as U=Uco1 + Uco2.

How can I get the expression U=Uco1 + Uco2 by using symbolic toolbox?

Thanks
From: Walter Roberson on
JinKyu wrote:

> I have a problem in using matlab symbolic toolbox.
> Here is the question.
>
> Let's imagine that we want to have the abbreviate expression for the
> complex expression.
> For example, the complex expression is shown below.
> U=2*(a*x+b*y+2*c*z) + (a*x + 3*b*(y^2))
>
> Here, all the variables (a, x, b, y, c, a) are symbolic.
> If symbolic variables such as Uco1 and Uco2 are defined as
> Uco1=2*(a*x+b*y+2*c*z) and
> Uco2=(a*x + 3*b*(y^2)), the U can be expressed as U=Uco1 + Uco2.
>
> How can I get the expression U=Uco1 + Uco2 by using symbolic toolbox?

You cannot. If Uco1 is defined as having a value then the symbolic
toolbox will automatically substitute that value, with the exception of
functions and possibly of arrays. (In Maple, whether the value is
substituted or not is a matter of whether the symbol has the "last name
eval" property, which is true for Maple functions, arrays, modules, and
some other objects.)

With some effort, it may be possible to reach an expression similar to

U = uneval(Uco1) + uneval(Uco2)

which in Maple would be pretty-printed as

U = 'Uco1' + 'Uco2'

but you will find that uneval() is a fleeting property, easily lost.

The more general approach to this kind of task in Maple would be to use
the algsubs() call. I have not determined what the equivalent MuPad call is.