Elements in a matrix

5 visualizaciones (últimos 30 días)
Maik Petersen
Maik Petersen el 4 de En. de 2014
Respondida: Maik Petersen el 4 de En. de 2014
Hello,
When I have a certain matrix, is there a possibility to check whether some value is on more than one position in the matrix.
So for example the identity matrix 3-by-3, how can I check whether the value '1' is multiple times there in the matrix?
Thanks in advance.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 4 de En. de 2014
Idx=find(A==1)

Más respuestas (2)

Walter Roberson
Walter Roberson el 4 de En. de 2014
sum(TheMatrix(:) == TheValue) > 1
In the more general case where you want to know whether any value is repeated, see unique()

Maik Petersen
Maik Petersen el 4 de En. de 2014
You guys are great, thanks!

Categorías

Más información sobre Creating and Concatenating Matrices 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