Search code examples
matlabcharcell

Str to double in matlab


I have a variable lets say x, that contain chars as follow :

123123213
343423434
454545455
....

If i do :

x(1) = 1 
x(1,1:9) = 123123213

I want to be able to get when i write :

x(1)=123123213 

I tried doing:

s=[cellstr(x)];
t=[str2double(s)];

Then i got "t" something like that :

ans =

1.0e+020 *

   1.1352
   1.1006
   1.0835
   ....

Image explaining :

http://i60.tinypic.com/2vv8jo6.png
http://i60.tinypic.com/2dbs3t3.png

If it helps im using matlab 7.12 .


Solution

  • Maybe str2num:

    x = ['123123123';'343423434';'454545455']
    
    x_num = str2num(x);
    
    x_num(1)
    
    ans =
    
       123123123