Converting alphanumeric to numeric format in MATLAB

Hello,

If would like to turn out string to number elements, you can try this:

Use str2num function to convert a character array to the numeric value represented by that string:

str = '37.294e-1';

val = str2num(str)
val =
    3.7294

The str2double function converts a cell array of strings to the double-precision values represented by the strings:

Note: double elements which are currently represented in string format, they are in {}

c = {'37.294e-1'; '-58.375'; '13.796'};

d = str2double(c)
d =
    3.7294
  -58.3750
   13.7960

That’s all,

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s