필터 지우기
필터 지우기

nc file creation in matlab

조회 수: 2 (최근 30일)
Tanmoyee Bhattacharya
Tanmoyee Bhattacharya 2015년 8월 5일
댓글: Tanmoyee Bhattacharya 2016년 5월 4일
I have a lot of ascii files with different lat lon. Like
65.125 5.125 1901 1 1 -999
65.375 5.125 1901 1 1 -999
65.625 5.125 1901 1 1 -999
65.875 5.125 1901 1 1 -999
66.125 5.125 1901 1 1 -999
... plus 1352 more lines
... the full file is attached
I have to create nc file. How can I do it.
  댓글 수: 1
per isakson
per isakson 2016년 3월 20일
I edited the question and moved the data to an attachment.

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

채택된 답변

KSSV
KSSV 2016년 3월 21일
clc ; clear all ;
data = importdata('nc.txt') ;
lon = data(:,1) ;
lat = data(:,2) ;
ncfile = 'myncfile.nc' ;
% Longitude
nccreate(ncfile,'lon','Dimensions',{'lon',1,length(lon)},'DeflateLevel',5) ;
ncwrite(ncfile,'lon',lon) ;
ncwriteatt(ncfile,'lon','long_name','longitude');
ncwriteatt(ncfile,'lon','units','degrees');
% Latitude
nccreate(ncfile,'lat','Dimensions',{'lat', 1, length(lat)},'DeflateLevel',5) ;
ncwrite(ncfile,'lat',lat)
ncwriteatt(ncfile,'lat','long_name','latitude');
ncwriteatt(ncfile,'lat','units','degrees');
  댓글 수: 3
KSSV
KSSV 2016년 3월 22일
I see that all the values are the same. Procedure is the same.
parameter = data(:,3) ;
nccreate(ncfile,'param','Dimensions',{'lon',1,length(parameter)},'DeflateLevel',5) ;
ncwrite(ncfile,'param',parameter) ;
parameter is the name of the physical property which third column signifies.
Tanmoyee Bhattacharya
Tanmoyee Bhattacharya 2016년 5월 4일
Sir IF my the variable RF is in 129*135 file matrix format how can I save it as a variable rainfall in .nc file format.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by