find number position

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

find number position

turbofib
hi,
i want to find lowest number position
a=[5 18 4 nan]
sort(a)

4 5 18 nan

if i write :

find(a==4) is not correct...i get  ans = 0



how can i position lowest number? thank you







--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: find number position

Doug Stewart-4


On Thu, Oct 11, 2018 at 8:09 PM turbofib <[hidden email]> wrote:
hi,
i want to find lowest number position
a=[5 18 4 nan]
sort(a)

4 5 18 nan

if i write :

find(a==4) is not correct...i get  ans = 0



how can i position lowest number? thank you







--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html




this works for me :-)
a=[5 18 4 nan]
b=sort(a)
b(1)
c=find(a==b(1))


--
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

Re: find number position

Pantxo
In reply to this post by turbofib
turbofib wrote

> hi,
> i want to find lowest number position
> a=[5 18 4 nan]
> sort(a)
>
> 4 5 18 nan
>
> if i write :
>
> find(a==4) is not correct...i get  ans = 0
>
>
>
> how can i position lowest number? thank you
> --
> Sent from:
> http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

Hi,

The following works perfectly:

find (min (a))

and

find (a==4)

returns 3, as expected.

Pantxo



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: find number position

Anton Dereventsov
The following works perfectly:
find (min (a))   

'find(min(a))' returns 1 since min(a) is a number, I think you meant 'find(a==min(a))', which returns 3.
You can also run '[m,im] = min(a)', which returns m = 4 (minimum), im = 3 (position of minimum).

Anton


On Fri, Oct 12, 2018 at 3:50 AM Pantxo <[hidden email]> wrote:
turbofib wrote
> hi,
> i want to find lowest number position
> a=[5 18 4 nan]
> sort(a)
>
> 4 5 18 nan
>
> if i write :
>
> find(a==4) is not correct...i get  ans = 0
>
>
>
> how can i position lowest number? thank you
> --
> Sent from:
> http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

Hi,

The following works perfectly:

find (min (a))

and

find (a==4)

returns 3, as expected.

Pantxo



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html




Reply | Threaded
Open this post in threaded view
|

Re: find number position

Ian McCallion
In reply to this post by turbofib
On Fri, 12 Oct 2018, 01:10 turbofib, <[hidden email]> wrote:
hi,
i want to find lowest number position
a=[5 18 4 nan]
sort(a)

4 5 18 nan

if i write :

find(a==4) is not correct...i get  ans = 0

how can i position lowest number? thank you

[~,p]=min(a); %p is the position of lowest number in a.