How to find unique lines in cell arrays

1 次查看(过去 30 天)
How to find unique lines in the next cell array:
15 'm'
18 'm'
15 'm'
So the result will be:
15 'm'
18 'm'

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-8-7
use unique function
  2 个评论
Artyom
Artyom 2013-8-7
Unique works only with cell array of strings.
Azzi Abdelmalek
Azzi Abdelmalek 2013-8-7
a={15 'm'; 18 'm'; 15 'm';13 'r';15 'm'}
b=cellfun(@num2str,a,'un',0)
c=arrayfun(@(x) horzcat(b{x,:}),(1:size(a,1))','un',0)
[idx,idx]=unique(c)
out=a(idx,:)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by