4.0

4.0 | 1 rating Rate this file 120 downloads (last 30 days) File Size: 1014 Bytes File ID: #10005

collapse.m

by Gerald Dalley

 

15 Feb 2006 (Updated 21 Feb 2006)

No BSD License  

Removes degenerate portions of a cell array tree.

Download Now | Watch this File

File Information
Description

%c = collapse(c)
% Takes a recursive cell array as a tree and collapses any branches
% having a fanout of 1. Any elements with fanout of 0 are removed.
%
%Examples:
% collapse({1 2 3}) --> {1 2 3}
% collapse({{1} {2} {{3}}}) --> {1 2 3}
% collapse({1 {2 3}}) --> {1 {2 3}}
% collapse({1 {{} 2 {{}} 3}}) --> {1 {2 3}}
% collapse({{{}}}) --> {}
%
% [matches] = regexp({'abc', 'def', 'fghi'}, '[^f]*f+[^f]*', 'match');
% collapse(matches) --> {'def' 'fghi'}
%

MATLAB release MATLAB 7.0.4 (R14SP2)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
18 Feb 2006 John D'Errico

Good documentation, it does what it claims to do.

Please login to add a comment or rating.
Updates
21 Feb 2006

Removed boilerplate copyright.

Tag Activity for this File
Tag Applied By Date/Time
structures Gerald Dalley 22 Oct 2008 08:15:55
cell arrays Gerald Dalley 22 Oct 2008 08:15:55
tree Cristina McIntire 23 Feb 2009 15:36:29
cell Cristina McIntire 23 Feb 2009 15:36:29
collapse Cristina McIntire 23 Feb 2009 15:36:29
branch Cristina McIntire 23 Feb 2009 15:36:29
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com