Converting a mat grid file to xyz

7 ビュー (過去 30 日間)
Safriyanti Rahayu
Safriyanti Rahayu 2019 年 5 月 22 日
回答済み: Manish Jangid 2020 年 10 月 22 日
I have grid mat file that is struct field
GSM_GRID.mat struct with fields:
  1. time: [117×1 double]
  2. grid_data_grace: [180×360×117 double] --> the size (grid_data_grace)= 180 * 360 which mean each value in grid have xy and values in every time.
  3. str_year: {1×117 cell}
  4. str_month: {1×117 cell}
I am trying to convert grid_data_grace to xyz each time (117) in csv file. BUt, I don't know how to convert it.
I have problem in converting it each time. the following is the code that I use to convert it.
s= load('GSM_GRID.mat');
value={{'time','grid_data_grace','str_year','str_month'}};
%s=struct(M,'grid_data_grace')
[lon,lat]=size(grid_data_grace)
lon=0.5:359.5;
lat=89.5:-1:-89.5;
s= M.grid_data_grace
file=fopen('ewh.csv','w');
for y=1:180;
for x=1:360;
fprintf(file,strcat(num2str(lat(y)),',',num2str(lon(x)),','));
fprintf(file, '%.16g,',s(y,x));
fprintf(file,'\n');
end
end
fclose(file);

回答 (2 件)

KSSV
KSSV 2019 年 5 月 22 日
A = rand( [180,360,117) ;
for i = 1:117
T = A(:,:,i) ;
iwant = T(:)
end

Manish Jangid
Manish Jangid 2020 年 10 月 22 日
i have a grd file downloded from IMD website which temp data file. can read this file matlab? is yes than how?

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by