i want to find row indices for each column having non zero values
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sravan Kumar
el 25 de Mzo. de 2016
i have a matrix a=[1 1 0 1;1 1 0 0;0 0 1 1] i want row indices for each column having non zero elements as [1,2] [1,2] [3] [1,3]
0 comentarios
Respuesta aceptada
Más respuestas (1)
Jos (10584)
el 25 de Mzo. de 2016
A = [1 1 0 1; 1 1 0 0; 0 0 1 1]
C = arrayfun(@(k) find(A(:,k)),1:size(A,2),'un',0)
% C{x} holds the row numbers for which A(:,x) is non-zero
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!