Replace vector duplicates with unique numbers
이전 댓글 표시
I have a D-dimension vector and I want to obtain a vector where duplicates are replaced by random numbers in [1,D]. The final vector must have all different values from 1 to D preserving non-duplicates order.
For example take D=6:
[2,4,5,4,1,2]
Isolate the unique numbers:
[2,4,5,-,1,-]
Then put the remaining 3 and 6 values:
[2,4,5,6,1,3] or [2,4,5,3,1,6]
What's an efficient way to do it?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Library Development에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!