Discussion:
find number position
turbofib
2018-10-12 00:09:10 UTC
Permalink
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
Doug Stewart
2018-10-12 01:11:50 UTC
Permalink
Post by turbofib
hi,
i want to find lowest number position
a=[5 18 4 nan]
sort(a)
4 5 18 nan
find(a==4) is not correct...i get ans = 0
how can i position lowest number? thank you
--
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))
--
DAS[image: Certificate for 206392]

<https://linuxcounter.net/user/206392.html>
Pantxo
2018-10-12 07:49:29 UTC
Permalink
Post by turbofib
hi,
i want to find lowest number position
a=[5 18 4 nan]
sort(a)
4 5 18 nan
find(a==4) is not correct...i get ans = 0
how can i position lowest number? thank you
--
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
Anton Dereventsov
2018-10-12 22:45:14 UTC
Permalink
Post by Pantxo
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
Post by Pantxo
Post by turbofib
hi,
i want to find lowest number position
a=[5 18 4 nan]
sort(a)
4 5 18 nan
find(a==4) is not correct...i get ans = 0
how can i position lowest number? thank you
--
http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Hi,
find (min (a))
and
find (a==4)
returns 3, as expected.
Pantxo
--
http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Ian McCallion
2018-10-12 23:13:11 UTC
Permalink
Post by turbofib
hi,
i want to find lowest number position
a=[5 18 4 nan]
sort(a)
4 5 18 nan
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.
Loading...