Code covered by the BSD License  

Highlights from
String to Cells

Be the first to rate this file! 4 Downloads (last 30 days) File Size: 1.43 KB File ID: #6054

String to Cells

by Cole Stephens

 

14 Oct 2004 (Updated 20 Oct 2010)

Split a single string into a cell array.

| Watch this File

File Information
Description

Take a single string and separate out individual "elements" into a new cell array. Elements are defined as non-blank characters separated by spaces.

Similar to str2cell, except str2cell requires an array of strings. str2cells requires only 1 string.

Example: Consider the following string in the workspace:
aString = ' a b c d efgh ij klmnopqrs t u v w xyz '
 
 >> newCell=str2cells(aString)'
 
 newCell =
 
     'a'
     'b'
     'c'
     'd'
     'efgh'
     'ij'
     'klmnopqrs'
     't'
     'u'
     'v'
     'w'
     'xyz'

Acknowledgements
This submission has inspired the following:
rsplit
MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
18 Oct 2004 Fahad Al Mahmood

This function does the same thing as the function (explode) created by Sara Silva.

19 Oct 2004 urs Schwarz (us)

1) what is str2cell? where does it live?
2) no need for this, really:
newCell=strread(aString,'%s')

Please login to add a comment or rating.
Updates
20 Oct 2010

Updated License Info.

Tag Activity for this File
Tag Applied By Date/Time
strings Cole Stephens 22 Oct 2008 07:33:10
string Cole Stephens 22 Oct 2008 07:33:10
cells Cole Stephens 22 Oct 2008 07:33:10
cellstr Cole Stephens 22 Oct 2008 07:33:10
utilities Cole Stephens 22 Oct 2008 07:33:10
string manipulation Cole Stephens 22 Oct 2008 07:33:10

Contact us at files@mathworks.com