MATLAB: str2double (convert strings to numbers - double data type)

Опубликовано: 11 Октябрь 2024
на канале: Engineering with Dr. Kelsey Joy
1,201
21

This short covers the MATLAB built-in function STR2DOUBLE() used for converting strings to doubles.

STR2DOUBLE() converts numbers that are currently a string or char data type to a double data type, so they can be used as a number. When an input argument does not meet this requirement (e.g., double number, text that is not a number), then the function returns NaN (for not a number). To check for NaN, use the ISNAN() built-in MATLAB function.

STR2NUM() is a similar function that you can also convert string versions of number to doubles, check out this video on it:    • MATLAB: str2num (convert strings to n...  

For a more detailed discussion around the STR2DOUBLE() and NUM2STR() functions, check out this video:    • MATLAB: String Functions - str2double...  

NUM2STR() is a function that does the opposite - it converts double data types to strings, check out this video on it:    • MATLAB: num2str (convert numbers/doub...  

Check out this playlist of string function videos:    • MATLAB String Functions series  

Check out this playlist of MATLAB shorts:    • MATLAB shorts  

For a full MATLAB tutorial, check out this playlist:    • How to Create Programs in MATLAB (tut...