MATLAB Answers

How to use unique function here

2 views (last 30 days)
NA on 6 Mar 2020
Answered: Bhaskar R on 6 Mar 2020
I have
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

Accepted Answer

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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!