Unable to read the .grd file using grdread2.m function

I am trying to read the attached 'file1.GRD' file using the code below. The function 'grdread2.m' is downloaded from MATLAB file exchange, as recommended in one fo the previous posts.
filename = 'file1.GRD';
[x,y,z] = grdread2(filename);
However, it is giving me errors listed below. Could someone help me?
Error using netcdf.open (line 52)
Could not open file 'Mintemp_MinT_2019.grd'.
Error in grdread2 (line 61)
ncid = netcdf.open(file, 'NC_NOWRITE');
Error in ReadnplotGRD (line 2)
[x,y,z] = grdread2(filename);

4 个评论

The function grdread2 (https://mathworks.com/matlabcentral/fileexchange/25683-grdread2) is one of the several submissions in MATLAB File Exchange on MATLAB Central, which is a forum for our product users to interact, exchange information and knowledge, without MathWorks' involvement. Hence I would suggest to contact the author of this submission directly for any questions related to it.
You have not attched the said file.
Sorry, I failed to previously see that the forum gave file format error when I tried to upload .grd file directly. I have compressed and attached the file now.
I shall also contact the original author.
Thank you for responding to this question.
I am having the same problem, can anyone help?

请先登录,再进行评论。

 采纳的回答

'fopen' worked for me. Sample code is appended below
filename=['XYZ.grd'];
fileID = fopen(filename);
output = fread(fileID,'float');

3 个评论

Thank @SKP for your response.
yes, the you have shared it is working. Output showing 2d vector data (350765*1) instead of matrix.
How did you open IMD data (Mintemp_MinT_2019.grd)? I am looking for the same data.
Please use 'reshape' function to change a vector into a matrix
hello @SKP
for 0.25 deg rainfall data i have used reshape function as
rainfall = reshape(rf, 135,129); (vector size = 17415*1)
it is working properly but for temperature data, how can I create matrix as it is showing on website that data is arranged into 31 X 31
thanks.

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Data Import and Export 的更多信息

产品

版本

R2020b

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by