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:
mpower input to eig must not contain nan or inf

Subject: mpower input to eig must not contain nan or inf

From: Carl S.

Date: 13 Nov, 2012 12:26:13

Message: 1 of 8

Hi,

I want to compute the derivative of 10^-2*s when s<1 and s>0

So, I wrote this :
10^(-2*s))*log(10)*(-2)

But I am getting the error : "mpower input to eig must not contain nan or inf"

How can I solve this error ?
Carl

Subject: mpower input to eig must not contain nan or inf

From: Carl S.

Date: 13 Nov, 2012 12:32:14

Message: 2 of 8

"Carl S." wrote in message <k7te95$f2o$1@newscl01ah.mathworks.com>...
> Hi,
>
> I want to compute the derivative of 10^-2*s when s<1 and s>0
>
> So, I wrote this :
> 10^(-2*s))*log(10)*(-2)
>
> But I am getting the error : "mpower input to eig must not contain nan or inf"
>
> How can I solve this error ?
> Carl

The equation which I want to compute its derivative is 10^(-2*s)

Subject: mpower input to eig must not contain nan or inf

From: Alan_Weiss

Date: 13 Nov, 2012 13:05:25

Message: 3 of 8

On 11/13/2012 7:32 AM, Carl S. wrote:
> "Carl S." wrote in message <k7te95$f2o$1@newscl01ah.mathworks.com>...
>> Hi,
>>
>> I want to compute the derivative of 10^-2*s when s<1 and s>0
>>
>> So, I wrote this :
>> 10^(-2*s))*log(10)*(-2)
>>
>> But I am getting the error : "mpower input to eig must not contain
>> nan or inf"
>>
>> How can I solve this error ?
>> Carl
>
> The equation which I want to compute its derivative is 10^(-2*s)

To perform symbolic computation you need Symbolic Math Toolbox, and you
must declare your variable as symbolic.

 >> syms s
 >> fcn = 10^(-2*s)

fcn =

1/10^(2*s)

 >> diff(fcn)

ans =

-2/10^(2*s)*log(10)

Alan Weiss
MATLAB mathematical toolbox documentation

Subject: mpower input to eig must not contain nan or inf

From: Carl S.

Date: 13 Nov, 2012 13:27:10

Message: 4 of 8

Alan_Weiss <aweiss@mathworks.com> wrote in message <k7tgil$msj$1@newscl01ah.mathworks.com>...
> On 11/13/2012 7:32 AM, Carl S. wrote:
> > "Carl S." wrote in message <k7te95$f2o$1@newscl01ah.mathworks.com>...
> >> Hi,
> >>
> >> I want to compute the derivative of 10^-2*s when s<1 and s>0
> >>
> >> So, I wrote this :
> >> 10^(-2*s))*log(10)*(-2)
> >>
> >> But I am getting the error : "mpower input to eig must not contain
> >> nan or inf"
> >>
> >> How can I solve this error ?
> >> Carl
> >
> > The equation which I want to compute its derivative is 10^(-2*s)
>
> To perform symbolic computation you need Symbolic Math Toolbox, and you
> must declare your variable as symbolic.
>
> >> syms s
> >> fcn = 10^(-2*s)
>
> fcn =
>
> 1/10^(2*s)
>
> >> diff(fcn)
>
> ans =
>
> -2/10^(2*s)*log(10)
>
> Alan Weiss
> MATLAB mathematical toolbox documentation

Thanks Alan. My codes are now;
a=(s>=0) & (s<=1);
b=(s>1);
ps= a.*((-2/10^(2*s))*log(10))+b.*(s-1);

But, I am getting this error : "mrdivide Matrix dimensions must agree" :(

Subject: mpower input to eig must not contain nan or inf

From: Carl S.

Date: 13 Nov, 2012 13:32:13

Message: 5 of 8

"Carl S." wrote in message <k7thre$rdd$1@newscl01ah.mathworks.com>...
> Alan_Weiss <aweiss@mathworks.com> wrote in message <k7tgil$msj$1@newscl01ah.mathworks.com>...
> > On 11/13/2012 7:32 AM, Carl S. wrote:
> > > "Carl S." wrote in message <k7te95$f2o$1@newscl01ah.mathworks.com>...
> > >> Hi,
> > >>
> > >> I want to compute the derivative of 10^-2*s when s<1 and s>0
> > >>
> > >> So, I wrote this :
> > >> 10^(-2*s))*log(10)*(-2)
> > >>
> > >> But I am getting the error : "mpower input to eig must not contain
> > >> nan or inf"
> > >>
> > >> How can I solve this error ?
> > >> Carl
> > >
> > > The equation which I want to compute its derivative is 10^(-2*s)
> >
> > To perform symbolic computation you need Symbolic Math Toolbox, and you
> > must declare your variable as symbolic.
> >
> > >> syms s
> > >> fcn = 10^(-2*s)
> >
> > fcn =
> >
> > 1/10^(2*s)
> >
> > >> diff(fcn)
> >
> > ans =
> >
> > -2/10^(2*s)*log(10)
> >
> > Alan Weiss
> > MATLAB mathematical toolbox documentation
 
Thanks Alan. My codes are now;

[phi_x,phi_y]=gradient(phi);
s=sqrt(phi_x.^2 + phi_y.^2);
a=(s>=0) & (s<=1);
b=(s>1);
ps= a.*((-2/10^(2*s))*log(10))+b.*(s-1);
 
 But, I am getting this error : "mrdivide Matrix dimensions must agree" :(

Subject: mpower input to eig must not contain nan or inf

From: Alan Weiss

Date: 13 Nov, 2012 18:44:11

Message: 6 of 8

"Carl S." wrote in message <k7ti4t$sio$1@newscl01ah.mathworks.com>...
> "Carl S." wrote in message <k7thre$rdd$1@newscl01ah.mathworks.com>...
> > Alan_Weiss <aweiss@mathworks.com> wrote in message <k7tgil$msj$1@newscl01ah.mathworks.com>...
> > > On 11/13/2012 7:32 AM, Carl S. wrote:
> > > > "Carl S." wrote in message <k7te95$f2o$1@newscl01ah.mathworks.com>...
> > > >> Hi,
> > > >>
> > > >> I want to compute the derivative of 10^-2*s when s<1 and s>0
> > > >>
> > > >> So, I wrote this :
> > > >> 10^(-2*s))*log(10)*(-2)
> > > >>
> > > >> But I am getting the error : "mpower input to eig must not contain
> > > >> nan or inf"
> > > >>
> > > >> How can I solve this error ?
> > > >> Carl
> > > >
> > > > The equation which I want to compute its derivative is 10^(-2*s)
> > >
> > > To perform symbolic computation you need Symbolic Math Toolbox, and you
> > > must declare your variable as symbolic.
> > >
> > > >> syms s
> > > >> fcn = 10^(-2*s)
> > >
> > > fcn =
> > >
> > > 1/10^(2*s)
> > >
> > > >> diff(fcn)
> > >
> > > ans =
> > >
> > > -2/10^(2*s)*log(10)
> > >
> > > Alan Weiss
> > > MATLAB mathematical toolbox documentation
>
> Thanks Alan. My codes are now;
>
> [phi_x,phi_y]=gradient(phi);
> s=sqrt(phi_x.^2 + phi_y.^2);
> a=(s>=0) & (s<=1);
> b=(s>1);
> ps= a.*((-2/10^(2*s))*log(10))+b.*(s-1);
>
> But, I am getting this error : "mrdivide Matrix dimensions must agree" :(

Perhaps the problem is the lack of a dot in 10^(2*s); maybe 10.^(2*s) would be better. But maybe not--I have to say I do not really understand what you are trying to do. Sorry.

Alan Weiss
MATLAB mathematical toolbox documentation

Subject: mpower input to eig must not contain nan or inf

From: Carl S.

Date: 14 Nov, 2012 04:58:17

Message: 7 of 8

"Alan Weiss" <alan.weiss.REMOVE.THIS@mathworks.com> wrote in message <k7u4dr$co1$1@newscl01ah.mathworks.com>...
> "Carl S." wrote in message <k7ti4t$sio$1@newscl01ah.mathworks.com>...
> > "Carl S." wrote in message <k7thre$rdd$1@newscl01ah.mathworks.com>...
> > > Alan_Weiss <aweiss@mathworks.com> wrote in message <k7tgil$msj$1@newscl01ah.mathworks.com>...
> > > > On 11/13/2012 7:32 AM, Carl S. wrote:
> > > > > "Carl S." wrote in message <k7te95$f2o$1@newscl01ah.mathworks.com>...
> > > > >> Hi,
> > > > >>
> > > > >> I want to compute the derivative of 10^-2*s when s<1 and s>0
> > > > >>
> > > > >> So, I wrote this :
> > > > >> 10^(-2*s))*log(10)*(-2)
> > > > >>
> > > > >> But I am getting the error : "mpower input to eig must not contain
> > > > >> nan or inf"
> > > > >>
> > > > >> How can I solve this error ?
> > > > >> Carl
> > > > >
> > > > > The equation which I want to compute its derivative is 10^(-2*s)
> > > >
> > > > To perform symbolic computation you need Symbolic Math Toolbox, and you
> > > > must declare your variable as symbolic.
> > > >
> > > > >> syms s
> > > > >> fcn = 10^(-2*s)
> > > >
> > > > fcn =
> > > >
> > > > 1/10^(2*s)
> > > >
> > > > >> diff(fcn)
> > > >
> > > > ans =
> > > >
> > > > -2/10^(2*s)*log(10)
> > > >
> > > > Alan Weiss
> > > > MATLAB mathematical toolbox documentation
> >
> > Thanks Alan. My codes are now;
> >
> > [phi_x,phi_y]=gradient(phi);
> > s=sqrt(phi_x.^2 + phi_y.^2);
> > a=(s>=0) & (s<=1);
> > b=(s>1);
> > ps= a.*((-2/10^(2*s))*log(10))+b.*(s-1);
> >
> > But, I am getting this error : "mrdivide Matrix dimensions must agree" :(
>
> Perhaps the problem is the lack of a dot in 10^(2*s); maybe 10.^(2*s) would be better. But maybe not--I have to say I do not really understand what you are trying to do. Sorry.
>
> Alan Weiss
> MATLAB mathematical toolbox documentation

I am trying to increase application performance by writing the
ps= a.*((-2/10^(2*s))*log(10))+b.*(s-1);
instead of ps=a.*sin(2*pi*s)/(2*pi)+b.*(s-1);

When I use the sin function the application works correctly, but I dont want to use the trigonometric function. Therefore, I have updated the ps value by writing the logaritmic equation.
Thanks Alan, I have tried 10.^(2*s) but as you guess, it still gives the same error :(
So, I am still need your help

Subject: mpower input to eig must not contain nan or inf

From: Steven_Lord

Date: 14 Nov, 2012 15:10:22

Message: 8 of 8



"Carl S." <tkittler@gmail.com> wrote in message
news:k7ti4t$sio$1@newscl01ah.mathworks.com...
> "Carl S." wrote in message <k7thre$rdd$1@newscl01ah.mathworks.com>...
>> Alan_Weiss <aweiss@mathworks.com> wrote in message
>> <k7tgil$msj$1@newscl01ah.mathworks.com>...
>> > On 11/13/2012 7:32 AM, Carl S. wrote:
>> > > "Carl S." wrote in message
>> > > <k7te95$f2o$1@newscl01ah.mathworks.com>...
>> > >> Hi,
>> > >>
>> > >> I want to compute the derivative of 10^-2*s when s<1 and s>0
>> > >>
>> > >> So, I wrote this :
>> > >> 10^(-2*s))*log(10)*(-2)
>> > >>
>> > >> But I am getting the error : "mpower input to eig must not contain
>> > >> nan or inf"
>> > >>
>> > >> How can I solve this error ?
>> > >> Carl
>> > >
>> > > The equation which I want to compute its derivative is 10^(-2*s)
>> >
>> > To perform symbolic computation you need Symbolic Math Toolbox, and you
>> > must declare your variable as symbolic.
>> >
>> > >> syms s
>> > >> fcn = 10^(-2*s)
>> >
>> > fcn =
>> >
>> > 1/10^(2*s)
>> >
>> > >> diff(fcn)
>> >
>> > ans =
>> >
>> > -2/10^(2*s)*log(10)
>> >
>> > Alan Weiss
>> > MATLAB mathematical toolbox documentation
>
> Thanks Alan. My codes are now;
>
> [phi_x,phi_y]=gradient(phi);
> s=sqrt(phi_x.^2 + phi_y.^2); a=(s>=0) & (s<=1);
> b=(s>1);
> ps= a.*((-2/10^(2*s))*log(10))+b.*(s-1);
>
> But, I am getting this error : "mrdivide Matrix dimensions must agree" :(

Change:

(-2/10^(2*s))

to:

(-2./10.^(2*s))

to perform _elementwise_ exponentiation and division instead of the _matrix_
forms of those operations.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

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