Code covered by the BSD License  

Highlights from
Flatten cell array

2.0
2.0 | 1 rating Rate this file 8 Downloads (last 30 days) File Size: 1.3 KB File ID: #43621 Version: 1.0

Flatten cell array

by

 

converts a nested cell array into a flat cell array

| Watch this File

File Information
Description

converts a nested cell array into a flat cell array

MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
18 Apr 2015 Yung-Yeh

Yung-Yeh (view profile)

I tried c = {'',[],'1','2',{'a','b','c',{'x','y','z'},'r'},[123],@isempty} but it's not flatted.

26 Sep 2013 Jan Simon

Jan Simon (view profile)

You use "cellfun(@(c) ~isempty(c), cell_array)" and "cellfun(@isempty, c)". While the 2nd method is more efficient, the built-in commands defined as string are still faster, because they do not call Matlab from the MEX level: "cellfun('isempty', c)".

"cat(1, c, ctemp(:)" is faster than the elementwise extraction and re-combination "c = [c{:}, ctemp{:}];".

Comment only

Contact us