Borrar filtros
Borrar filtros

find non zero elements put in a matrix

2 visualizaciones (últimos 30 días)
babis
babis el 5 de Dic. de 2013
Respondida: Wayne King el 5 de Dic. de 2013
i have a matrix and i want to take the row number of every non-zero element per collumn into a new matrix

Respuestas (1)

Wayne King
Wayne King el 5 de Dic. de 2013
A = randi([-2 2],20,10);
idx = find(A~=0);
B = A(idx);
B contains all the nonzero elements of A, but how will you know the size of the matrix ahead of time?

Categorías

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