convert string to number array in matlab

后端 未结 3 1443
小鲜肉
小鲜肉 2020-12-02 01:00

I have a script in which a string of number is entered

string=\'123\'

or

string=\'9823\'

I am trying to

相关标签:
3条回答
  • 2020-12-02 01:07

    use the function str2num()

    str = '123';
    str = str2num(str);
    

    Note: To verify that i'm correct, type in 'whos str' in the command window, and check the class. A string has a class, char, and numeric values have a class, double

    0 讨论(0)
  • 2020-12-02 01:13

    You can use cellstr:

    cellstr('123')
    ans =
    {
      [1,1] = 123
    }
    
    0 讨论(0)
  • 2020-12-02 01:14
    str = '123';
    num = str - '0';
    % num = [1 2 3];
    
    0 讨论(0)
提交回复
热议问题