sscanf
Read formatted data from strings
Syntax
Description
reads data from A = sscanf(str,formatSpec)str, converts it according to the format
specified by formatSpec, and returns the results in an array.
str is either a character array or a string scalar. The
sscanf function repeatedly applies
formatSpec to sequences of characters in
str until it either reaches the end of str
or fails to match formatSpec to a sequence of characters. If
str is a character array with more than one row,
sscanf reads the characters in column order.
sets the size of the output array to be A = sscanf(str,formatSpec,sizeA)sizeA and then reads data
from str into the output array. sizeA must be
a positive integer or have the form [m n], where
m and n are positive integers.
Examples
Input Arguments
Output Arguments
Tips
Format specifiers for the reading functions
sscanfandfscanfdiffer from the formats for the writing functionssprintfandfprintf. The reading functions do not support a precision field. The width field specifies a minimum for writing, but a maximum for reading.
Extended Capabilities
Version History
Introduced before R2006a