Assign different strings in a cell array with a number
이전 댓글 표시
I have a cell array that contains a lot of strings, where sometimes the string is repeated throughout the array. I want to assign a number to the different strings. So for example in my cell array I have names:
Harry
Jenny
Harry
Ben
So in this case Harry would be assigned the number 1 Jenny the number 2 and Ben the number 3. The probelm is that my cell array contains over a million names so I do not know what all of them are. Is there a way to create a code such that whenever the code comes across a new name it assigns it a number?
Thanks!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!