Borrar filtros
Borrar filtros

nc file creation in matlab

2 visualizaciones (últimos 30 días)
Tanmoyee Bhattacharya
Tanmoyee Bhattacharya el 5 de Ag. de 2015
Comentada: Tanmoyee Bhattacharya el 4 de Mayo de 2016
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 comentario
per isakson
per isakson el 20 de Mzo. de 2016
I edited the question and moved the data to an attachment.

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 21 de Mzo. de 2016
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 comentarios
KSSV
KSSV el 22 de Mzo. de 2016
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 el 4 de Mayo de 2016
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.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by