omit same element inside cell
Show older comments
A={[1,2,3,4],[4,2,3],[1,2,5,6,78,9],[1,2,3,4],[1,2,5,6,78,9],[4,2,3],[5,6,7]};
c=cellfun(@(x) unique(x),A,'UniformOutput',false);
I want to omit same array inside cell
result should be
A={[1,2,3,4],[4,2,3],[1,2,5,6,78,9],[5,6,7]};
2 Comments
madhan ravi
on 3 Apr 2019
?? [4,2,3] & [5,6,7] have the same size there is something wrong in your logic or your explanation
NA
on 3 Apr 2019
Accepted Answer
More Answers (1)
Jos (10584)
on 3 Apr 2019
You can convert the elements of each cell to a char array and apply unique on that cell array of chars.
A = {[1,2,3,4],[4,2,3],[1,2,5,6,78,9],[1,2,3,4],[1,2,5,6,78,9],[4,2,3],[5,6,7]};
% engine
[~,ix] = unique(cellfun(@(x) num2str(x), A ,'un', 0), 'stable') ;
B = A(ix) % as requested
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!