What does this do?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
harleykitten
el 17 de Jul. de 2016
Respondida: Walter Roberson
el 17 de Jul. de 2016
I can't figure out what this bit of code is doing:
[m,n]=find(min(a))
I know that it is not returning the indices of the minimum entries in the array 'a', but what is it doing?
0 comentarios
Respuesta aceptada
Azzi Abdelmalek
el 17 de Jul. de 2016
Editada: Azzi Abdelmalek
el 17 de Jul. de 2016
[m,n]=min(a)
m is the minimum, n is the index of n m in a
You can try an example
a=[4 7 3 6 2 7 8]
[m,n]=min(a)
Now if you write
r=find(min(a))
you will find the result
r=1
because in our example min(a)=2, it contains just one elment, so there is one index=1
0 comentarios
Más respuestas (1)
Walter Roberson
el 17 de Jul. de 2016
If a is a 2D or more array, then min(a) would return the minimum along the first dimension. Some of those minima might be negative, some might be positive, some might be 0. find() applied to that is going to return the indices of the non-zero elements within that minima. For example if a is 2D array then [m,n]=find(min(a)) is going to return the indices of the columns where the minima is non-zero.
0 comentarios
Ver también
Categorías
Más información sobre Operators and Elementary Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!