Eliminate zeros from array
조회 수: 2 (최근 30일)
이전 댓글 표시
I have to arrays: A=[0 1 0 4; 2 0 3 4] and B= [1 2 3 4; 5 6 7 8]
I want to eleiminate zeros from matrix A and the corresponding values from matrix B. The solution is:
A=[1 4 2 3 4] and B=[2 4 5 7 8]
댓글 수: 0
답변 (1개)
James Tursa
2018년 4월 30일
AT = reshape(A',1,[]);
BT = reshape(B',1,[]);
B = BT(AT~=0);
A = AT(AT~=0);
댓글 수: 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!