Borrar filtros
Borrar filtros

How to save index of Values of an item in a matrix?

1 visualización (últimos 30 días)
Robert
Robert el 17 de Mzo. de 2023
Respondida: Dyuman Joshi el 17 de Mzo. de 2023
I have a matrix of of elements like
[0,0,0,1,0,0,0,0,1,0,1]
I'd like to go through the matrix and at each element where the value is greater than zero, I want to save the index to a new matrix such that the new matrix looks like:
[4, 9, 11]

Respuestas (1)

Dyuman Joshi
Dyuman Joshi el 17 de Mzo. de 2023
x=[0,0,0,1,0,0,0,0,1,0,1];
y=find(x>0)
y = 1×3
4 9 11

Categorías

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

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by