MATLAB: Convert a string to number

str2num

Hi, I want to convert a string into a number however I don't want to use str2num since I loose extra digits (see example below). Can I use some other MATLAB function?
data = 0.0782238;
s = str2num(data); %Don't want this since s = 0.0782 and I'm loosing three extra digits

Best Answer

str2num() does not lose those extra digits. Instead, you are not displaying the full width of the number. At the MATLAB command line give the command
format long g
and try your code again.