Convert decimal number to vector

前端 未结 3 1251
一向
一向 2021-01-29 00:16

In matlab I want to convert this:

12345.6788993442355456789

into a vector

[1 2 3 4 5 6 7 8 8 9 9 3 4 4 2 3 5 5 4 5 6 7 8 9]
         


        
3条回答
  •  梦毁少年i
    2021-01-29 00:53

    Also using num2str, you can do:

    sol=arrayfun(@str2num,(sprintf('%f',23432.23432)),'UniformOutput',0)
    horzcat(sol{:})
    
    ans =
    
         2     3     4     3     2     2     3     4     3
    

    Do you want to keep the information about where is the comma?

提交回复
热议问题