how to use find command to find numbers?

4 visualizaciones (últimos 30 días)
Andy
Andy el 2 de Abr. de 2012
Comentada: the cyclist el 20 de Feb. de 2016
so say if i have
a=[1;2;3;4;5;6;7;8;9]
and i want to find which position the number 5 is.
so i tried to use
position = find (a,5)
but it gives me back a whole bunch of numbers. so how do i use the find command? thanks

Respuesta aceptada

the cyclist
the cyclist el 2 de Abr. de 2012
You want
position = find(a==5);
Your example is maybe not the best, since the position and the value are the same in every case, but just to be clear on what you mean:
x = [2 5 7 4 3];
position = find(x==5)
will return position = 2, because 5 is in the 2nd position in x.
FYI, in the syntax you used in your example, MATLAB was returning the positions of the first 5 non-zero entries of a.
  2 comentarios
Rohit Bhoi
Rohit Bhoi el 19 de Feb. de 2016
then how to use find function to find value in particular row of excel sheet
the cyclist
the cyclist el 20 de Feb. de 2016
(You might want to open a new question, rather than commenting on a 4-year-old question.)
First you need to load the data from Excel. You can do this with the xlsread command. Then you can use find as described here.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by