String to Double Conversion in MATLAB
Advertisement
This page provides MATLAB source code for converting a string to a double number, similar to the str2double function. The str2double MATLAB function converts a string input to a double-precision output value.
output = str2double(str1)
If str1 does not contain a valid scalar value, the function returns NaN (Not a Number).
str1 can be a single element or an array.
Example:
str2double({'2.50' '4.222'})
Another Example:
str1 = '1.25 + 50i'
output = str2double(str1)
This would produce the following output:
output =
1.2500 +50.0000i
Explore MATLAB Data Types, Strings & Conversions
- Binary to Decimal Conversion in MATLAB
- Binary to Hex Conversion in MATLAB
- Decimal to Base-N Conversion in MATLAB
- Decimal to Binary Conversion in MATLAB
- Decimal to Hexadecimal Conversion in MATLAB (dec2hex)
- Hex to Binary Conversion in MATLAB
- Hexadecimal String to Double Conversion in MATLAB
- Number to Hexadecimal String Conversion in MATLAB
- Number to String Conversion in MATLAB (num2str)
- String to Double Conversion in MATLAB
- String to Number Conversion in MATLAB (str2num)
- MATLAB Matrix to String (mat2str)
- Base-N Number String to Decimal in MATLAB
