image thumbnail

Read numbers from a string.

version (2.84 KB) by DS
The function PARSE_NUMBERS applies SSCANF to read numbers from delimited string.


Updated 28 Mar 2012

View License

A = PARSE_NUMBERS(S) separates the string, S, into a cell array of substrings which are individually scanned to determine numeric values; results are returned in matrix A.

The behavior of PARSE_NUMBERS can be modified by additional options which are specified as propertyName/propertyValue string pairs; lists of values can be specified as cell arrays of strings.

'del' --delimeter strings
'key' --identifier strings
'dec' --alternative decimal strings
'fmt' --format string passed to sscanf

Please note: There are many ways to achieve similar results by applying one or more of the built-in Matlab string handling functions directly.

Good info here:
and here:

Also of interest, see the function 'expandstr' in submission FEX 12180.

Cite As

DS (2021). Read numbers from a string. (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!