Ale*_*lec 5 matlab scientific-notation
我有一个问题,如'313397E9'等8位数字符串被传入excel,然后读作数字'313397000000000'或'3.133970e + 014'.
然后由Matlab读取并将其识别为数字,而不是字符串.将它转换回8位数字符串的最简单方法是什么?
在此先感谢您的帮助.
正规表达救援!您可以使用REGEXPREP将尾随零转换为Ex,其中x是您刚刚替换的零的数量.
%# convert the number to a string
nn = num2str(3.133970e+014)
nn =
313397000000000
%# replace zeros using regexprep
regexprep(nn,'([0]*)','E${num2str(length($1))}')
ans =
313397E9
Run Code Online (Sandbox Code Playgroud)
这也适用nn于字符串的单元格数组,顺便说一句,因此您可以一次性转换您的数字列表.