Parsing a string into a vector

Søren Hauberg soren at hauberg.org
Sun Feb 8 06:00:09 CST 2009


søn, 08 02 2009 kl. 03:37 -0800, skrev AlexG1:
> I need to parse a string containing numbers (e.g. '1 2 3 4 5') into a
> numeric vector.
> In Matlab I simply used the strread() function, but I don't see any
> equivalent for it in Octave. I've tried using strtok() but I can't get it
> work properly, and it's pretty ugly anyway.

Is 'str2num' what you want?

str2num ('1 2 3 4 5')
ans =

   1   2   3   4   5

Søren



More information about the Help-octave mailing list