File Exchange

image thumbnail

str2cell: a pedestrian cell creator

version 1.0 (1.72 KB) by

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

4.42857
8 Ratings

5 Downloads

Updated

View License

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]

Comments and Ratings (8)

Mugiho

Mugiho (view profile)

Thank you a lot !! this is very very much help for my source coding ~!

Mugiho

Mugiho (view profile)

Mitchell

Zhijun Wang

Thank you very much!!!!!!!

kiran doijode

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

John D'Errico

A nice function.

Marcelo Zeri

Excellent, exactly what I needed!

Suhas Gajre

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

Updates

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

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

changed help and added preallocation of cell[s]

MATLAB Release
MATLAB 6.5 (R13)
Acknowledgements

Inspired: char2cell

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video