matlab - Unique Columns Across an Array? -


i have array structured so:

a = [1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 5 5 5 5;      1 1 1 1 2 2 2 2 2 2 2 1 1 1 1 2 2 3 3 1 1 1 2 3 4 4 4 1 1 1 1 2 2 3 3];  

pretty much, it's 2 n (i simplified matrix in question reduced number of columns simplicity's sake), no real pattern. want able find unique number of columns. in simplified example, can (but it'll take while) count hand , noticed unique matrix b is:

b=  1 1 2 2 2 3 3 3 3 4 5 5      1 2 1 2 3 1 2 3 4 1 2 3 

in matlab, can like

size(b,2)  

to number of unique columns. in example

size(b,2) = 12 

my question is, how go matrix matrix b can computationally large n dimensional matrices have?

use unique:

a = [1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 5 5 5 5;     1 1 1 1 2 2 2 2 2 2 2 1 1 1 1 2 2 3 3 1 1 1 2 3 4 4 4 1 1 1 1 2 2 3 3];  % transpose leverage rows flag, transpose b = unique(a.', 'rows').'; 

which returns:

b =       1     1     2     2     2     3     3     3     3     4     5     5      1     2     1     2     3     1     2     3     4     1     2     3 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -