4.33333

4.3 | 6 ratings Rate this file 12 Downloads (last 30 days) File Size: 1.72 KB File ID: #4247

str2cell: a pedestrian cell creator

by us

 

13 Dec 2003 (Updated 07 Jun 2005)

creates a cell array from an input vector of any valid ML datatype

| Watch this File

File Information
Description

help str2cell

  c = str2cell(v)
  c = str2cell(v,delim[s])
 
  creates a cell array C from input vector V.
  places segments of V seperated by delimiter
  DELIM into separate cells of C.
 
  see also: CELLSTR
 
  v : a string/vector of a ML supported data class
  delim : array of delimiter[s] [def: isspace]
  v-class syntax
  ----------------------
  char 'xyz'
  other [1 2 pi]
 
  note:
  an input matrix (NxM) will be turned into a
  1x(N*M) column vector WITHOUT warning!
 
  examples:
  s='this is a ;;; test string; +-0 ;;;_;;; for; +;+ fun;';
  c=str2cell(s,' +-;0_')
  'this'
  'is'
  'a'
  'test'
  'string'
  'for'
  'fun'
 
  d=[pi pi 1 2 inf 4 5 6 nan 78 pi];
  c=str2cell(d,[nan pi 5 inf])
  [1x2 double] % = 1 2
  [ 4]
  [ 6]
  [ 78]

Acknowledgements
This submission has inspired the following:
char2cell
MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
13 Dec 2004 Suhas Gajre

This is a good program! I needed this today and found it almost instantly here! Thanks Urs (us) Schwarz.

17 Feb 2005 Marcelo Zeri

Excellent, exactly what I needed!

20 Nov 2005 John D'Errico

A nice function.

01 Jan 2007 kiran doijode

i needded it urgently thank u!!!!!!!!!!

11 Oct 2007 Zhijun Wang

Thank you very much!!!!!!!

07 Mar 2012 Mitchell  
Please login to add a comment or rating.
Updates
17 Dec 2003

changed help and added preallocation of cell[s]

22 Dec 2003

added NANs to be valid delimiters. version 20/12/2003 20:08:38.

24 Dec 2003

added a critical print suppressor! version 24/12/2003 00:34:41.

07 Jun 2005

finally, after 5 years, added a missing ; at the end of line 62... sorry for the delay

Tag Activity for this File
Tag Applied By Date/Time
matrices us 22 Oct 2008 07:10:52
char us 22 Oct 2008 07:10:52
string us 22 Oct 2008 07:10:52
double us 22 Oct 2008 07:10:52
datatype us 22 Oct 2008 07:10:52
class us 22 Oct 2008 07:10:52
cell us 22 Oct 2008 07:10:52
tokenize us 22 Oct 2008 07:10:52
parse us 22 Oct 2008 07:10:52

Contact us at files@mathworks.com