I have array value like this snippet below:
a = { [1 2 4]; [3 5 6 7]; [1 2 4]; [3 5 6 7]; [8 9]; []};
I am trying Matlab to get array value like this
a = { [1 2 4]; [3 5 6 7];[8 9]};
I have array value like this snippet below:
a = { [1 2 4]; [3 5 6 7]; [1 2 4]; [3 5 6 7]; [8 9]; []};
I am trying Matlab to get array value like this
a = { [1 2 4]; [3 5 6 7];[8 9]};
unique(cellfun(@(x)(mat2str(x)),a,'uniformoutput',false))
This can be found here actually.
Technically the empty cell at the end is also unique, perhaps you want to remove it separately like so:
a(cellfun(@isempty,a)) = []
Currently you get strings as output, this can be solved like so:
[~, idx] = unique(cellfun(@(x)(mat2str(x)),a,'uniformoutput',false))
a(idx)
I personally think that this is harder than it should be.
You can get your desired output like so
a(cellfun(@isempty,a)) = []
[~, idx] = unique(cellfun(@(x)(mat2str(x)),a,'uniformoutput',false))
a(idx)