How can I concatenate only the contents of the cells in a cell array whose length is more than a specific number?
Afficher commentaires plus anciens
I have a cell array (r) as given below.
r{1,1} = [1 2]
r{1,2} = 1x15 double which is like [3 4 ......17]
r{1,3} = [18 19]
r{1,4} = 1x16 double which is [20 21 ......35]
r{1,5} = 1x5 double [36 37 38 39 40]
it goes on till
r{31,1} = [107 108 109];
How can I concatenate only the contents of the cells whose length is more than 4? My output should be a single array which looks like [3 4 5..........17 20 21 ....35 36 37 38 39 40.....] Only the cells which have more than 4 elements should get concatenated.
Thanks in advance
Réponse acceptée
Plus de réponses (1)
Sean de Wolski
le 20 Mar 2015
One liner
Rcat = [R{cellfun(@length,R)>4}];
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!