Filter löschen
Filter löschen

find non zero elements put in a matrix

2 Ansichten (letzte 30 Tage)
babis
babis am 5 Dez. 2013
Beantwortet: Wayne King am 5 Dez. 2013
i have a matrix and i want to take the row number of every non-zero element per collumn into a new matrix

Antworten (1)

Wayne King
Wayne King am 5 Dez. 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?

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by