【matlab】[Z,R] = arcgridread(filename);读取小数问题

[Z,R] = arcgridread(filename);filename文件为.grd的网格文件,里面的值为浮点数,直接读取的时候出错,只能读取第一个浮点数,而且自动转化为了整数。

在matlab命令行里输入open arcgridread.打开arcgridread.m文件,看它内部实现代码,修改如下即可读取出小数:

% Read the matrix of data values, putting the k-th row in the data
% file into the k-th column of matrix Z.  Close file — nothing left to
% read after this.
%%这是系统的%d,下面的%f是自己修改的。
% [Z, count] = fscanf(fid,’%d’,[ncols,nrows]);
[Z, count] = fscanf(fid,’%f’,[ncols,nrows]);
fclose(fid);

    原文作者:Z字形编排问题
    原文地址: https://blog.csdn.net/dreamflyhua/article/details/19164259
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞