필터 지우기
필터 지우기

find non zero elements put in a matrix

조회 수: 2 (최근 30일)
babis
babis 2013년 12월 5일
답변: Wayne King 2013년 12월 5일
i have a matrix and i want to take the row number of every non-zero element per collumn into a new matrix

답변 (1개)

Wayne King
Wayne King 2013년 12월 5일
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?

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by