Converting first column unique values to number
조회 수: 6 (최근 30일)
이전 댓글 표시
I have a table that I need to use for another function.
Currently the table is setup as
Base1,x,y,z
Base1,x,y,z
Building2,x,y,z
Building2,x,y,z
Complex3,x,y,z
Complex3,x,y,z
Complex3,x,y,z
What I would like to do is rename the first column if they have unique names so Base1 would switch to 1, Building2 switches to 2 ect...
Is there an easy way to rename all of the first column based on if the values are unique or not?
댓글 수: 2
채택된 답변
Matt J
2019년 6월 28일
편집: Matt J
2019년 6월 28일
[~,~,u]=unique(yourTable{:,1},'stable');
yourTable{:,1}=num2cell(u)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Other Formats에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!