nccreatewrite
버전 2.0.0.1 (283 KB) 작성자:
ANKUR KUMAR
Creates the NetCDF file directly, and these NetCDF files are readbale in GrADS. Get rid of writing the long commands everytime to create
Function:
One can create a NetCDF file with the predefined MATLAB
function using nccreate and ncwrite. This function is a
combination of these two predefined functions. One can use this
to save the time and get rid of writing the same commands for
storing multi variables in a nc file.
Syntax:
nccreatewrite('sample_file.nc','variable',{'lon','lat','lev'},randi(20,20,30,5))
Inputs:
First input should be the name of the nc file in which you want
to store the data.
Second input should be the name of the variable in which you
want to store the specific variable.
Third argument should be in braces (not structure) which must
contains the number of variables as that of the size of the
data you want to store.
ex: If you want to store 'lat' whose dimensions is 5*1, then
third argument should be {'lat'}
The above is becasue of MATLAB also stores the variable
dimensions seprately, not in the variable list.
You can see this when you use ncdisp to see the listed
variables in nc file.
Fourth argument should be the data you want to write in nc
file.
Fifth argument is an optional argument, and if provided, it should
be the attributes of the variable.
Example:
random_data = normrnd(3,10,[20,30,5])+273;
filename='sample.nc';
delete(filename)
lon_att.standard_name='longitude';
lon_att.long_name='longitude';
lon_att.units='degrees_east';
lon_att.axis='X';
nccreatewrite(filename,'lon',{'lon'},[65:84],lon_att)
lat_att.standard_name='latitude';
lat_att.long_name='latitude';
lat_att.units='degrees_north';
lat_att.axis='Y';
nccreatewrite(filename,'lat',{'lat'},[1:30],lat_att)
lev_att.long_name='generic';
lev_att.units='level';
lev_att.axis='Z';
nccreatewrite(filename,'lev',{'lev'},[1:5],lev_att)
nccreatewrite(filename,'TC',{'lon','lat','lev'},random_data)
ncdisp(filename)
Please send your suggestions to the email id: ankurk017@gmail.com or
ankur.kumar@nsstc.uah.edu
인용 양식
ANKUR KUMAR (2025). nccreatewrite (https://www.mathworks.com/matlabcentral/fileexchange/65636-nccreatewrite), MATLAB Central File Exchange. 검색 날짜: .
MATLAB 릴리스 호환 정보
개발 환경:
R2021a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux카테고리
Help Center 및 MATLAB Answers에서 MATLAB Compiler SDK에 대해 자세히 알아보기
태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!