Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
matlab科学符号问题_Matlab_Scientific Notation - Fatal编程技术网

matlab科学符号问题

matlab科学符号问题,matlab,scientific-notation,Matlab,Scientific Notation,我遇到一个问题,将一个8位字符串(如“313397E9”)传递到excel中,然后读取为数字“31339700000000”或“3.133970e+014” 然后由Matlab读取并识别为数字,而不是字符串。将其转换回8位字符串的最简单方法是什么 提前感谢您的帮助。您可以使用将后面的零转换为Ex,其中x是您刚刚替换的零的数量 %# convert the number to a string nn = num2str(3.133970e+014) nn = 313397000000000 %

我遇到一个问题,将一个8位字符串(如“313397E9”)传递到excel中,然后读取为数字“31339700000000”或“3.133970e+014”

然后由Matlab读取并识别为数字,而不是字符串。将其转换回8位字符串的最简单方法是什么

提前感谢您的帮助。

您可以使用将后面的零转换为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

顺便说一句,如果
nn
是一个字符串单元格数组,这也适用,因此您可以一次性转换数字列表

您必须告诉我们MATLAB和excel之间的通信机制。它使用actxserver打开excel,然后获取特定的工作表,然后获取值=(sheet.Range(['A2:A32000']).value)。这些都是我没有编写的大量代码中的内容,可能不应该弄乱它们。一旦它是一个数字,有没有办法将它转换回8位数?这些数字是如何存储在MATLAB中的。它们真的是弦吗?您希望如何将它们存储在Excel中?字符串或数字?如果您想停止Excel转换为数字,那么我认为您应该能够使用这样的表示法:
'1234
另请参见:是否将31339000000000.0恢复为313390E9或31339E10?工作非常完美!事实上,说得好,Jouni。。。我想根本无法知道这个值应该是多少…@Jouni:31339000000000被转换为31339E10-不确定这是否是OP的真正意图。当然,如果想法是总是有6位数字后跟E9,那么一切都将相当琐碎。此外,313390000000000.0将转换为313393E10.E1。但是,如果以3e+014这样的数字开头,则不应出现此输入。如果有必要,这当然可以在regexp中修复。字符串可以是313390E9或31339E10,但excel会将两者转换为3.13E+14。不过,E很可能即将结束,所以我想我将使用Jonas的解决方案,而不是修改5000个电子表格。