str2num

Purpose

String to number conversion.

Synopsis

x = str2num('str')

Description

x = str2num('str') converts the string str, which is an ASCII character representation of a numeric value, to MATLAB's numeric representation. The string can contain digits, a decimal point, a leading + or - sign, an e preceding a power of 10 scale factor, and/or an i for a complex unit.

Examples

str2num('3.14159e0') is approximately pi .

Algorithm

The M-file for x = str2num(s) is a single line:

eval(['x = ' s ';']);

See Also

hex2num, num2str, sscanf

(c) Copyright 1994 by The MathWorks, Inc.