How can I concatenate only the contents of the cells in a cell array whose length is more than a specific number?
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (1)
Sean de Wolski
am 20 Mär. 2015
One liner
Rcat = [R{cellfun(@length,R)>4}];
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!