I would like to ask how to find unique cells (with integer number NOT string) from cell array like this (size of A is always m x m):
A=({1,3,4} {4,7} {1,3,4};
{3,6} {4,7} {};
{1,3,4} {4,7} {4});
The results which I want to obtain is:
uniqueA = {1,3,4} {4,7} {3,6} {4}
Do you have any idea?
Best Regards Karolina
you can convert the cell to string fromat:
B = cellfun(@(x)(mat2str(x)),A,'uniformoutput',false);
Then use unique as usual:
[C,ia] = unique(B)
then use the index ia to point to unique cells with:
A{ia}
If you write A as follow :
A={[1,3,4] [4,7] [1,3,4]; [3,6] [4,7] []; [1,3,4] [4,7] [4]};
tmp = cellfun(@(x)(num2str(x)),A,'uniformoutput',false);
unique(tmp);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With