【问题标题】:why ncread function in matlab reduce floating point numbers count? [duplicate]为什么matlab中的ncread函数会减少浮点数? [复制]
【发布时间】:2017-11-10 17:17:11
【问题描述】:

我在 matlab 中有以下代码:

converted = ncread(this_file, 'U');
disp(converted(50,10,20));

结果是:

-0.1561

实际上这个数字是 -0.15617890 但这段代码改变了浮点数的数量。为什么?

【问题讨论】:

    标签: matlab netcdf


    【解决方案1】:

    默认情况下,MATLAB 仅显示小数点后 4 位。您可以使用format 显示更多位数:

    format long
    converted = ncread(this_file, 'U');
    disp(converted(50,10,20));
    

    【讨论】:

    • 在下一阶段我使用 csvwrite([test,'.txt'],converted);功能和同样的问题(我的数字较短):(请帮助我
    • @SiamakFarsi csvwrite 最多写入五个有效数字。如果你需要更高的精度,你应该使用dlmwrite 代替:dlmwrite([test,'.txt'],converted,'precision',8);
    • dlmwrite dident 工作:(。仍然是相同的输出。csvwrite 和 dlmwrite 在浮动部分都有 7 位数字
    • @SiamakFarsi 尝试使用 '%.8f' 而不是 8 作为最后一个参数,以明确设置 8 位小数而不是 8 位有效数字(或增加值;使用 9 或更高)。
    • oh tnxxx gooooooood bless you my angel @frslm
    猜你喜欢
    • 2018-11-26
    • 2019-09-10
    • 1970-01-01
    • 1970-01-01
    • 2021-05-14
    • 2011-03-03
    • 1970-01-01
    • 2015-02-05
    • 1970-01-01
    相关资源
    最近更新 更多