data structures - How to concatenate and uniquify lists in matlab -


i've got matlab structure looks like

pointlesshorror  ans =  {   [1,1] =        1   17   20    [2,1] =        2   17   18   21 ...   [16,1] =       16   39   40  } 

and

misery = [1 2 3] 

and want lists associated each v

pointlesshorror(1) # 1 17 20 pointlesshorror(2) # 2 17 18 21 pointlesshorror(3) # 3 18 19 23 

and put them together

[ 1 17 20 2 17 18 21 3 18 19 23 ] 

and uniquify them

unique([ 1 17 20 2 17 18 21 3 18 19 23 ]) 

to @ end

[  1    2    3   17   18   19   20   21   23 ] 

unfortunately, has fast, , way make matlab fast express one-liners, , wondering how say:

(distinct (concat (map pointlesshorror misery))) 

in matlab these particular data structures.

and if has general tips finding out answers these sort of problems, type of variable, , operations can on it, they'd appreciated too.

you seem have figured out already, apart concatenating multiple entries of pointlesshorror @ once. luckily simple: if index cell array vector, comma-separated list, concatenated this:

pointlesshorrorconcat = [ pointlesshorror{[ 1 2 3 ]} ]; 

so here full example:

pointlesshorror = { [ 1 17 20 ], [ 2 17 18 21 ], [ 16 39 60 ] } misery = [ 1 2 3 ] result = unique([ pointlesshorror{misery} ]) 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -