sscanf

Purpose

Read string under format control.

Synopsis

A = sscanf(s,'format')
A = sscanf(s,'format',size)
[A,count] = sscanf(...)

Description

A = sscanf(s,'format') reads data from the MATLAB string variable s, converts it according to the specified format string, and returns it in matrix A.

A = sscanf(s,'format',size) specifies the number of elements to generate.

[A,count] = sscanf(...) also returns the number of elements successfully read.

sscanf is the same as fscanf except that it reads the data from a MATLAB string variable rather than reading it from a file. See fscanf for full information on how to use sscanf.

Example

The statements

s = '2.7183  3.1416';
A = sscanf(s,'%f')
create a two-element vector containing poor approximations to e and pi.

See Also

eval, fscanf, sprintf

(c) Copyright 1994 by The MathWorks, Inc.