在MATLAB中使用fscanf读取长浮点数据

弗里曼

我有一个txt文件,其中每一行的格式如下:

86 0.722932 0.334032 1.19402 0.719591 0.331065 1.19416

使用

fileID = fopen(filename,'r');
data_column = fscanf(fileID,'%f');

将数据转换为

86 0.7229 0.3340 1.1940 0.7195 0.3310 1.1941

如何保持原始精度?

布罗多尔

问题不在于您如何阅读文本文件,而在于如何在matlab中显示数字。尝试发行

format long g

在显示data_column向量之前。这是我的输出:

>> format long g
>> fileID = fopen('test.txt','r');
>> data_column = fscanf(fileID,'%f')

data_column =

                        86
                  0.722932
                  0.334032
                   1.19402
                  0.719591
                  0.331065
                   1.19416

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章