Table Of Contents

strread

Version:
    Last Modified: March 15, 2017

    Reads data from an input string according to the format and option you specify.

    Syntax

    c = strread(a)
    c = strread(a, format, n)
    c = strread(a, format, option, optionvalue)
    c = strread(a, format, n, option, optionvalue)
    [c1, c2, ...] = strread(a, format)
    [c1, c2, ...] = strread(a, format, n)
    [c1, c2, ...] = strread(a, format, option, optionvalue)
    [c1, c2, ...] = strread(a, format, n, option, optionvalue)

    Inputs

    a

    String to read.

    format

    Pattern to read. The number of output parameters must equal the number of items in format. If you specify '' instead of format, strread uses '%f' as the default pattern to read. You can only use '' as format for the syntax c = strread(a, format, n), c = strread(a, format, option, optionvalue), and c = strread(a, format, n, option, optionvalue).

    n

    Amount of formatted data to read.

    option

    Specifies how to treat the characters in a. option is a string that accepts the following values.

    Name Description
    'commentstyle'

    Ignores the characters that follow comment characters. MathScript recognizes comment characters according to the language you specify in optionvalue.

    'delimiter'

    Treats optionvalue as a new delimiter character.

    'expchars'

    Treats optionvalue as a new exponent character.

    'whitespace'

    Treats each character in optionvalue as a new white space character. If optionvalue includes a backslash ('\'), the character after the backslash can be only 'n', 'r', 't', or '\'.

    optionvalue

    String depending on the setting of option. If option is 'commentstyle', optionvalue accepts the following values: 'matlab', 'shell', 'c', and 'C++'. If option is 'delimiter', optionvalue is a new delimiter character. If option is 'expchars', optionvalue is a new exponent character. If option is 'whitespace', each character in optionvalue is treated as a new white space character. If optionvalue includes a backslash ('\'), the character after the backslash can be only 'n', 'r', 't', or '\'.

    Default: 'e', 'E'

    Outputs

    c, c1, c2, ...

    Formatted data from the input string.

    str = sprintf('a, 1, 2\nb, 3, 4\n')
    [c1 c2 c3] = strread(str, '%s%d%d', 'delimiter', ',')

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: This product does not support FPGA devices


    Recently Viewed Topics