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

조회 수: 13 (최근 30일)
SKP
SKP 2021년 10월 1일
댓글: Aarti Soni 2023년 6월 7일
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
SKP
SKP 2021년 10월 4일
편집: SKP 2021년 10월 4일
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.
Aarti Soni
Aarti Soni 2023년 5월 31일
I am having the same problem, can anyone help?

댓글을 달려면 로그인하십시오.

채택된 답변

SKP
SKP 2023년 6월 1일
편집: SKP 2023년 6월 1일
'fopen' worked for me. Sample code is appended below
filename=['XYZ.grd'];
fileID = fopen(filename);
output = fread(fileID,'float');
  댓글 수: 3
SKP
SKP 2023년 6월 1일
Please use 'reshape' function to change a vector into a matrix
Aarti Soni
Aarti Soni 2023년 6월 7일
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개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by