replace duplicate value by 0 in matrix or vector
이전 댓글 표시
How do we replace duplicate value by 0 in matrix or vector ?
for example
Input:
b = 1 2 1 3
Output::
b= 1 2 0 3
Thanks
채택된 답변
추가 답변 (2개)
Adam
2019년 10월 15일
[C,ia] = unique( b );
b( setdiff( 1:numel(b), ia ) ) = 0;
Jos (10584)
2019년 10월 15일
% for small vectors:
b = [1 2 1 3 2 1 4 2]
b(sum(triu(b == b')) > 1) = 0
카테고리
도움말 센터 및 File Exchange에서 Discrete Data Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!