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:
error when using double()

Subject: error when using double()

From: Thomas Nguyen

Date: 17 Mar, 2012 06:52:23

Message: 1 of 3

Hello,

I keep getting an error when using the double function for the following code:

syms t;
u = 13.7;
s = 2.458;
a = 1/(sqrt(2*pi)*s)
b = exp((-1/(2*s^2))*(t-u)^2)
f1 = a*b
f2 = (t^(-2))*f1
double(int(f2,t,0,inf))

I did some research and tried to use

double(vpa(int(f2,t,0,inf)))

but I kept getting the same error. Any help would be greatly appreciated.

Thanks,
Tom

Subject: error when using double()

From: Nasser M. Abbasi

Date: 17 Mar, 2012 07:33:30

Message: 2 of 3

On 3/17/2012 1:52 AM, Thomas Nguyen wrote:
> Hello,
>
> I keep getting an error when using the double function for the following code:
>
> syms t;
> u = 13.7;
> s = 2.458;
> a = 1/(sqrt(2*pi)*s)
> b = exp((-1/(2*s^2))*(t-u)^2)
> f1 = a*b
> f2 = (t^(-2))*f1
> double(int(f2,t,0,inf))
>
> I did some research and tried to use
>
> double(vpa(int(f2,t,0,inf)))
>
> but I kept getting the same error. Any help would be greatly appreciated.
>
> Thanks,
> Tom

The interesting thing is that the error message tells
you exactly all the problem(s) you had and what to do.

In addition, the error message says that the int() failed
to find an explicit integral.
---------------
Warning: Explicit integral could not be found.
....
If the input expression contains a symbolic variable, use the VPA function
instead.
--------------------

For example

----------------------------------
EDU>> clear all
EDU>> syms t
EDU>> expr=5847603923053631/(36028797018963968*t^2)
EDU>> double(expr)
??? Error using ==> mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double
array.
EDU>> vpa(expr)
0.16230361285656333403260020986636/t^2
--------------------------------

So, you need to use vpa() as the message says. Not double() and
not vpa(double()).

In your case, however, since int() itself was not
successful, as the message says, then no need to worry
about using vpa() before fixing the int() problem first.

reading the error messages always helps :)

--Nasser

Subject: error when using double()

From: Roger Stafford

Date: 18 Mar, 2012 16:23:11

Message: 3 of 3

"Thomas Nguyen" <tn55@drexel.edu> wrote in message <jk1cb7$nuu$1@newscl01ah.mathworks.com>...
> I keep getting an error when using the double function for the following code:
> syms t;
> u = 13.7;
> s = 2.458;
> a = 1/(sqrt(2*pi)*s)
> b = exp((-1/(2*s^2))*(t-u)^2)
> f1 = a*b
> f2 = (t^(-2))*f1
> double(int(f2,t,0,inf))
> ........
- - - - - - - - - -
  The reason for the "Warning: Explicit integral could not be found" message is that the integral int(f2,t,0,inf) is divergent. As the lower limit of integration approaches zero, the integral approaches infinity because of the 1/t^2 factor in f2. If you take the integral of just 1/t^2 from a to b you get -1/b+1/a which is clearly divergent as a approaches zero. The presence of the exponential factor in f2 does not alter this fact since that factor approaches a nonzero value as t approaches zero.

Roger Stafford

Tags for this Thread

No tags are associated with 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