matrix
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
if i want to find the index of certain value in 2D matrix, how can I find that? e.g: I have a 300x300 matrix. There is a value 90096 in that matriz. I want to find its index. Please show me the code.
0 comentarios
Respuesta aceptada
Andrei Bobrov
el 20 de Dic. de 2011
A =[ 191 23 37 34 154
212 66 228 99 9
30 128 224 215 199
214 225 114 186 219
148 226 188 225 159];
a = 224;
[i1,j1] = find(abs(A-a) < 100*eps);
2 comentarios
Walter Roberson
el 20 de Dic. de 2011
Yes! If you do not know for sure that the values are integral, then using exact comparisons will often fail.
Más respuestas (2)
Jim
el 20 de Dic. de 2011
you can use find command to know the index of values in matrix
0 comentarios
C.J. Harris
el 20 de Dic. de 2011
Using find with two return parameters might make it easier.
[row, col] = find(matrix == 90096);
3 comentarios
Walter Roberson
el 20 de Dic. de 2011
Probably the value in the matrix was not _exactly_ 90096
http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
Ver también
Categorías
Más información sobre Matrix Indexing 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!