Separating digits in decimal representation of integer

后端 未结 3 346
我在风中等你
我在风中等你 2021-01-17 05:10

I want to take user input entered as an integer, for example (45697), and store the first two digits in an array, vector, or something else such as ( 4 5

3条回答
  •  北海茫月
    2021-01-17 05:36

    Since you are interested in individual digits, you don't even need to invoke str2num. One way is enough as in x_str = num2str(x);, then you subtract '0' with y = x_str(1:2)-'0';.

提交回复
热议问题