Got Questions? Get Answers.
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:
Using syms in Matlab R2010a

Subject: Using syms in Matlab R2010a

From: VENU

Date: 31 Jan, 2011 19:12:04

Message: 1 of 9

I am numerically integrating a function and I get the following. I am using it on 2 different versions of matlab. The code works fine in Matlab R2008a but shows this error on R2010a ... I look up on web but I cant find any solutions.

The variable y0 is predefined.
*********************************************
??? Error using ==> mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a
double array.

If the input expression contains a symbolic variable, use the VPA function
instead.

Error in ==> sym.sym>sym.double at 927
            Xstr = mupadmex('mllib::double', S.s, 0);

Error in ==> evalc_0_31_jan at 18
I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));

****************************************

Suggestions are appreciated.

Thanks
V

Subject: Using syms in Matlab R2010a

From: Think two, count blue.

Date: 31 Jan, 2011 19:28:40

Message: 2 of 9

On 11-01-31 01:12 PM, VENU wrote:
> I am numerically integrating a function and I get the following. I am using it
> on 2 different versions of matlab. The code works fine in Matlab R2008a but
> shows this error on R2010a ... I look up on web but I cant find any solutions.
>
> The variable y0 is predefined.
> *********************************************
> ??? Error using ==> mupadmex
> Error in MuPAD command: DOUBLE cannot convert the input expression into a
> double array.
>
> If the input expression contains a symbolic variable, use the VPA function
> instead.
>
> Error in ==> sym.sym>sym.double at 927
> Xstr = mupadmex('mllib::double', S.s, 0);
>
> Error in ==> evalc_0_31_jan at 18
> I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));

If you remove the I = double() layer and display the results of the double
integration, what do you see output?

Would it not be safer in your two integration calls to specify the variable of
integration?

Subject: Using syms in Matlab R2010a

From: VENU

Date: 31 Jan, 2011 21:29:05

Message: 3 of 9

"Think two, count blue." <roberson@hushmail.com> wrote in message <ii72hf$avv$1@nrc-news.nrc.ca>...
> On 11-01-31 01:12 PM, VENU wrote:
> > I am numerically integrating a function and I get the following. I am using it
> > on 2 different versions of matlab. The code works fine in Matlab R2008a but
> > shows this error on R2010a ... I look up on web but I cant find any solutions.
> >
> > The variable y0 is predefined.
> > *********************************************
> > ??? Error using ==> mupadmex
> > Error in MuPAD command: DOUBLE cannot convert the input expression into a
> > double array.
> >
> > If the input expression contains a symbolic variable, use the VPA function
> > instead.
> >
> > Error in ==> sym.sym>sym.double at 927
> > Xstr = mupadmex('mllib::double', S.s, 0);
> >
> > Error in ==> evalc_0_31_jan at 18
> > I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));
>
> If you remove the I = double() layer and display the results of the double
> integration, what do you see output?
>
> Would it not be safer in your two integration calls to specify the variable of
> integration?

If I remove the double or use vpa instead of double, it wont evaluate the integral.
I tried specifying the variable and but it does not change anything.

Thanks
V

Subject: Using syms in Matlab R2010a

From: Think two, count blue.

Date: 31 Jan, 2011 21:49:08

Message: 4 of 9

On 11-01-31 03:29 PM, VENU wrote:
> "Think two, count blue." <roberson@hushmail.com> wrote in message
> <ii72hf$avv$1@nrc-news.nrc.ca>...
>> On 11-01-31 01:12 PM, VENU wrote:
>> > I am numerically integrating a function and I get the following. I am
>> using it
>> > on 2 different versions of matlab. The code works fine in Matlab R2008a but
>> > shows this error on R2010a ... I look up on web but I cant find any
>> solutions.
>> >
>> > The variable y0 is predefined.
>> > *********************************************
>> > ??? Error using ==> mupadmex
>> > Error in MuPAD command: DOUBLE cannot convert the input expression into a
>> > double array.
>> >
>> > If the input expression contains a symbolic variable, use the VPA function
>> > instead.
>> >
>> > Error in ==> sym.sym>sym.double at 927
>> > Xstr = mupadmex('mllib::double', S.s, 0);
>> >
>> > Error in ==> evalc_0_31_jan at 18
>> > I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));
>>
>> If you remove the I = double() layer and display the results of the double
>> integration, what do you see output?
>>
>> Would it not be safer in your two integration calls to specify the variable
>> of integration?
>
> If I remove the double or use vpa instead of double, it wont evaluate the
> integral.
> I tried specifying the variable and but it does not change anything.

And is f(x,y,y0) defined? If not then the result of the double integration is
going to be a symbolic expression in int() calls, and double() will not be
able to force those expressions to evaluate.

Could you break it down to a specific example that works in R2008a but not in
R2010a ?

Subject: Using syms in Matlab R2010a

From: VENU

Date: 1 Feb, 2011 01:47:03

Message: 5 of 9

"Think two, count blue." <roberson@hushmail.com> wrote in message <ii7aos$fcr$1@nrc-news.nrc.ca>...
> On 11-01-31 03:29 PM, VENU wrote:
> > "Think two, count blue." <roberson@hushmail.com> wrote in message
> > <ii72hf$avv$1@nrc-news.nrc.ca>...
> >> On 11-01-31 01:12 PM, VENU wrote:
> >> > I am numerically integrating a function and I get the following. I am
> >> using it
> >> > on 2 different versions of matlab. The code works fine in Matlab R2008a but
> >> > shows this error on R2010a ... I look up on web but I cant find any
> >> solutions.
> >> >
> >> > The variable y0 is predefined.
> >> > *********************************************
> >> > ??? Error using ==> mupadmex
> >> > Error in MuPAD command: DOUBLE cannot convert the input expression into a
> >> > double array.
> >> >
> >> > If the input expression contains a symbolic variable, use the VPA function
> >> > instead.
> >> >
> >> > Error in ==> sym.sym>sym.double at 927
> >> > Xstr = mupadmex('mllib::double', S.s, 0);
> >> >
> >> > Error in ==> evalc_0_31_jan at 18
> >> > I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));
> >>
> >> If you remove the I = double() layer and display the results of the double
> >> integration, what do you see output?
> >>
> >> Would it not be safer in your two integration calls to specify the variable
> >> of integration?
> >
> > If I remove the double or use vpa instead of double, it wont evaluate the
> > integral.
> > I tried specifying the variable and but it does not change anything.
>
> And is f(x,y,y0) defined? If not then the result of the double integration is
> going to be a symbolic expression in int() calls, and double() will not be
> able to force those expressions to evaluate.
>
> Could you break it down to a specific example that works in R2008a but not in
> R2010a ?

The function blows up at a point ... Here is an example where y0=0.5

*******************************************
f=inline('log((x).^2 + (y-0.5).^2)+ log ((y/2-1).^2 + (x/2).^2 )');
I=double(int(int(f(x,y),0,sqrt(1-y.^2)),-1,1))
*****************************************************

It works in the older version and I get I = -1.1781 but not it the new one.

Thanks
V

Subject: Using syms in Matlab R2010a

From: Think blue, count two.

Date: 1 Feb, 2011 17:51:11

Message: 6 of 9

On 31/01/11 7:47 PM, VENU wrote:

>> >> > ??? Error using ==> mupadmex
>> >> > Error in MuPAD command: DOUBLE cannot convert the input
>> expression into a
>> >> > double array.

>> >> > I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));

> The function blows up at a point ... Here is an example where y0=0.5
> *******************************************
> f=inline('log((x).^2 + (y-0.5).^2)+ log ((y/2-1).^2 + (x/2).^2 )');
> I=double(int(int(f(x,y),0,sqrt(1-y.^2)),-1,1))
> *****************************************************

When I transcribe this over to a new version of Maple, removing the
periods (Maple does not have a .^ operator), and not using "inline", I
encounter unexpected output from the first integration. The space after
the "log" throws Maple off, causing it to treat "log" as a constant to
be multiplied by the following term. When I remove that space that
problem does not occur. This should not be an issue with your use of
Matlab and inline().

Note, though, that when you use inline, the order of the arguments the
inline function will expect is not necessarily going to be obvious:
there is an algorithm that looks at the symbol names to determine the
order of the arguments.


Maple is not able to evaluate the integration without assistance,
warning that,

Warning, unable to determine if (-1/4-y^2+y)^(1/2) is between 0 and
(1-y^2)^(1/2); try to use assumptions or use the AllSolutions option
Warning, unable to determine if -(-1/4-y^2+y)^(1/2) is between 0 and
(1-y^2)^(1/2); try to use assumptions or use the AllSolutions option

Adding the assumptions that x and y are real-valued is enough to get rid
of the warnings, but not enough for Maple to be able to find a value for
the integration.

Maple is, however, able to process the inner integration if one adds the
assumption that y>=-1 and y<=1 . It is not then able to find a closed
form for the outer integration, but it is able to evaluate the outer
integration numerically.

I would thus suggest that in Matlab, you use assume() to add assumptions
on y before you attempt to process the integrations.

Subject: Using syms in Matlab R2010a

From: VENU

Date: 3 Feb, 2011 22:50:06

Message: 7 of 9

Thanks a lot for the analysis. I tried what you suggested but I don't know if matlab has a assume real function. And I want to do it matlab to able to integrate it with my other matlab files.

Venu

"Think blue, count two." <roberson@hushmail.com> wrote in message <kKX1p.56924$Y8.41406@newsfe06.iad>...
> On 31/01/11 7:47 PM, VENU wrote:
>
> >> >> > ??? Error using ==> mupadmex
> >> >> > Error in MuPAD command: DOUBLE cannot convert the input
> >> expression into a
> >> >> > double array.
>
> >> >> > I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));
>
> > The function blows up at a point ... Here is an example where y0=0.5
> > *******************************************
> > f=inline('log((x).^2 + (y-0.5).^2)+ log ((y/2-1).^2 + (x/2).^2 )');
> > I=double(int(int(f(x,y),0,sqrt(1-y.^2)),-1,1))
> > *****************************************************
>
> When I transcribe this over to a new version of Maple, removing the
> periods (Maple does not have a .^ operator), and not using "inline", I
> encounter unexpected output from the first integration. The space after
> the "log" throws Maple off, causing it to treat "log" as a constant to
> be multiplied by the following term. When I remove that space that
> problem does not occur. This should not be an issue with your use of
> Matlab and inline().
>
> Note, though, that when you use inline, the order of the arguments the
> inline function will expect is not necessarily going to be obvious:
> there is an algorithm that looks at the symbol names to determine the
> order of the arguments.
>
>
> Maple is not able to evaluate the integration without assistance,
> warning that,
>
> Warning, unable to determine if (-1/4-y^2+y)^(1/2) is between 0 and
> (1-y^2)^(1/2); try to use assumptions or use the AllSolutions option
> Warning, unable to determine if -(-1/4-y^2+y)^(1/2) is between 0 and
> (1-y^2)^(1/2); try to use assumptions or use the AllSolutions option
>
> Adding the assumptions that x and y are real-valued is enough to get rid
> of the warnings, but not enough for Maple to be able to find a value for
> the integration.
>
> Maple is, however, able to process the inner integration if one adds the
> assumption that y>=-1 and y<=1 . It is not then able to find a closed
> form for the outer integration, but it is able to evaluate the outer
> integration numerically.
>
> I would thus suggest that in Matlab, you use assume() to add assumptions
> on y before you attempt to process the integrations.

Subject: Using syms in Matlab R2010a

From: proecsm

Date: 4 Feb, 2011 23:27:04

Message: 8 of 9

"VENU " <venuiitg@gmail.com> wrote in message <iifbeu$nff$1@fred.mathworks.com>...
> Thanks a lot for the analysis. I tried what you suggested but I don't know if matlab has a assume real function. And I want to do it matlab to able to integrate it with my other matlab files.
>
> Venu

syms y real

Subject: Using syms in Matlab R2010a

From: VENU

Date: 8 Feb, 2011 20:47:04

Message: 9 of 9

That does not work either. Anyway thanks for the sugesstions.

Venu

"proecsm" wrote in message <iii208$jej$1@fred.mathworks.com>...
> "VENU " <venuiitg@gmail.com> wrote in message <iifbeu$nff$1@fred.mathworks.com>...
> > Thanks a lot for the analysis. I tried what you suggested but I don't know if matlab has a assume real function. And I want to do it matlab to able to integrate it with my other matlab files.
> >
> > Venu
>
> syms y real

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