How to determine the position of an integer
Mostrar comentarios más antiguos
Hi,
I have a very basic question. I have a variable containing 5 numbers, say for eg,
d= [1 4 3 2 5]
how can i find the position of the number 3 in this d. I tried to use Find but I think I am using it wrong . Can anyone help me out please.
Thanks,
Vivekram
Respuesta aceptada
Más respuestas (2)
Jim O'Doherty
el 9 de Mayo de 2013
0 votos
Hi Vivekram,
I'd sugget using the "unique" command
[C, ia, ic]=unique(d)
ic will give you the indices of the numbers in your array d
Jim
1 comentario
Vivekram
el 9 de Mayo de 2013
Grzegorz Knor
el 9 de Mayo de 2013
Editada: Grzegorz Knor
el 9 de Mayo de 2013
If the values are in the cell format use cell2mat function:
pos = find(cell2mat(d)==3)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!