How to use unique function here

조회 수: 3 (최근 30일)
NA
NA 2020년 3월 6일
답변: Bhaskar R 2020년 3월 6일
I have
A={{[1,3,4],[1],[2,3,4,6,8]},{[1,2,34],[1,2,3,4,5,6,7],[1,2,9,6,4],[1,3,4]},{[8,9],[2,3,4,6,8],[1,3,4]}};
A = cellfun(@(x) unique(x,'rows'),A,'uniformoutput',false);
when I want to use unique function it gives me this error
Error using cell/unique (line 4)
Cell array input must be a cell array of character vectors.
I want to have this result
A={[1,3,4],[1],[2,3,4,6,8],[1,2,34],[1,2,3,4,5,6,7],[1,2,9,6,4],[8,9]}

채택된 답변

Bhaskar R
Bhaskar R 2020년 3월 6일
inn_A = [A{:}];
str_A = cellfun(@(x)num2str(x(:)'),inn_A,'UniformOutput',false);
[~,idx,idx2] = unique(str_A);
Result = inn_A(idx);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by