find non zero elements put in a matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
i have a matrix and i want to take the row number of every non-zero element per collumn into a new matrix
댓글 수: 0
답변 (1개)
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?
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!