string to double in matlab

To convert a string to a double in Matlab use the str2double function. Here is an example:

main.m
str = '3.1416';
num = str2double(str);
39 chars
3 lines

This will convert the string '3.1416' to the number 3.1416. Note that if the string cannot be converted to a number then the result will be NaN (Not a Number).

related categories

gistlibby LogSnag