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:
format to see inf number

Subject: format to see inf number

From: Jose

Date: 29 Sep, 2010 11:55:05

Message: 1 of 5

Hello guys, I've got three high values of p:

>> p=[p1spikenew p2spikenew p3spikenew]

p =

   Inf Inf Inf

>> [junk,maximum]=max(p)

junk =

   Inf


maximum =

     1

Anyone can help me to know the exact value of p1spikenew,p2spikenew and p3spikenew, because matlab says that the biggest value is p1spikenew, but I can say it, because the three values are inf.

There are another kind of format to see it properly,
cheers.

Jose.

Subject: format to see inf number

From: David Young

Date: 29 Sep, 2010 12:17:23

Message: 2 of 5

All the values are "infinity" - there isn't any more information about what the "actual" values are. This means that your computation has produced a number that is larger than any number that Matlab can represent.

max is just returning an arbitrary element of the array - the fact you get a definite result from max does not mean that element 1 is bigger than the others, just that none of the others is bigger than element 1 (in Matlab, all infinities are equal).

Subject: format to see inf number

From: Steven_Lord

Date: 29 Sep, 2010 13:23:59

Message: 3 of 5



"Jose " <jose.l.vega@gmail.com> wrote in message
news:i7v9ep$l3e$1@fred.mathworks.com...
> Hello guys, I've got three high values of p:
>
>>> p=[p1spikenew p2spikenew p3spikenew]
>
> p =
>
> Inf Inf Inf
>
>>> [junk,maximum]=max(p)
>
> junk =
>
> Inf
>
>
> maximum =
>
> 1
>
> Anyone can help me to know the exact value of p1spikenew,p2spikenew and
> p3spikenew, because matlab says that the biggest value is p1spikenew, but
> I can say it, because the three values are inf.

If the array contains multiple instances of the maximum value (as is the
case with your p matrix) then the index returned will be the index of the
_first_ occurrence of the maximum value, as documented on the last sentence
of the Description section of the reference page for MAX.

http://www.mathworks.com/help/techdoc/ref/max.html

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: format to see inf number

From: Jos (10584)

Date: 29 Sep, 2010 13:52:06

Message: 4 of 5

"Steven_Lord" <slord@mathworks.com> wrote in message <i7velg$49p$1@fred.mathworks.com>...
* SNIP *
> If the array contains multiple instances of the maximum value (as is the
> case with your p matrix) then the index returned will be the index of the
> _first_ occurrence of the maximum value, as documented on the last sentence
> of the Description section of the reference page for MAX.
>
> http://www.mathworks.com/help/techdoc/ref/max.html

As a addition to this, you can use the following to get all locations of the maximum

x = [Inf Inf 0 Inf] % your values
mx = max(x) % maximum (Inf)
idx = find(x==mx) % all locations of the maximum

hth
Jos

Subject: format to see inf number

From: Jan Simon

Date: 29 Sep, 2010 19:21:19

Message: 5 of 5

Dear Jose,

> >> p=[p1spikenew p2spikenew p3spikenew]
> p =
> Inf Inf Inf
> >> [junk,maximum]=max(p)
> junk =
> Inf
> maximum =
> 1

A tiny experiment:
[junk, maximum] = max(p(end:-1:1))
 junk =
    Inf
 maximum =
      1
So the order of elements in p does not matter!

Jan

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