strread

Reads formatted data from a string (removed from recent MATLAB; use textscan).

Category: Language Fundamentals > Data Types

Syntax

[a, b, ...] = strread(str, format)

Parses str according to format, one output per conversion.

Description

strread was an early text parser, later superseded by textscan and sscanf. Current MATLAB recommends textscan for delimited text and sscanf for simple formats, and MatLivre follows that advice: it reports that strread has been removed.

The equivalent of [a, b] = strread(s, '%d %d') is c = textscan(s, '%d %d'), which returns a cell array with one column per conversion.

Input arguments

str
Text containing the data.
format
Conversion specifiers such as %d, %f and %s.

Output arguments

a, b, ...
One output for each conversion in format.

Example

Use textscan instead

try
  [a, b] = strread('1 2 3 4', '%d %d');
catch err
  disp(err.message)
end
c = textscan('1 2 3 4', '%d %d');
c{1}'
c{2}'
Output
strread has been removed; use textscan or strsplit.
ans = 1×2 int32 row vector

   1   3
ans = 1×2 int32 row vector

   2   4

Notes

Calling strread in MatLivre always raises the error shown in the example. Use textscan or sscanf.

See also

textscan sscanf str2double strsplit