Eliminate duplicates of nonzero elements but keep zeros
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
I have a logical array. I want to eliminate the duplicates of the 1s but keep all the zeros intact.
Here's an example of what I want.
A = [0 1 0 1 1 0 0 0 0 0 1 1 1 0 1]
new matrix = [0 1 0 1 0 0 0 0 0 1 0 1].
The zeros are the same but all the duplicate 1s after the first are eliminated.
댓글 수: 0
답변 (2개)
Azzi Abdelmalek
2013년 11월 27일
A = [0 1 0 1 1 0 0 0 0 0 1 1 1 0 1]
A(strfind(A,[1,1]))=[]
댓글 수: 2
Alice
2013년 11월 27일
Azzi Abdelmalek
2013년 11월 27일
A = [0 1 0 1 1 0 0 0 0 0 1 1 1 0 1];
B=A;
B(strfind(B,[1,1]))=[]
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!