how to delete duplicate values in a cell array of characters
2 ビュー (過去 30 日間)
古いコメントを表示
hi! I have this cell array of charachter:
a={'1';'1';'1';'1';'1';'3';'3';'3';'3';'3';'3';'4';'4';'4';'4'};
and I want to trasform it in this:
a={'1';'';'';'';'';'3';'';'';'';'';'';'4';'';'';''};
can you help me? thanks
0 件のコメント
採用された回答
Julian Hapke
2016 年 2 月 9 日
a={'1';'1';'1';'1';'1';'3';'3';'3';'3';'3';'3';'4';'4';'4';'4'};
[~,c,~]=unique(a);
tmp=true(size(a));
tmp(c)=false;
[a{tmp}] = deal('')
3 件のコメント
Guillaume
2016 年 2 月 9 日
I would have the last line as:
a(tmp) = {''};
I'm sure it involves less work in the background than cell array to comma separated list + deal expansion.
Julian Hapke
2016 年 2 月 10 日
you're right, that's the cleaner way. I often have trouble getting the cell array syntax right...
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!