% define the directory where the raw files are stored datadir=fullfile('..','raw'); % check which files are in the data directory files=dir(fullfile(datadir, '*.txt')); % we're just doing the first one (renamed from filename because this was % used as output) %dataset=xlsread(fullfile(datadir, files(1).name)); dataset=load(fullfile(datadir, files(1).name)); % the file contains 3 columns stormid=dataset(:,1); rmd=dataset(:,2); gm=dataset(:,3); windspd=dataset(:,4); windir=dataset(:,5); % check how many columns we have npoints = 385656; %npoints = length(lat); % we assume that all 3 columns have the same length, better check it... %assert(length(x) == length(y)) %assert(length(x) == length(elev)) % this is the file we're saving results to filename=('wind_micore.nc'); nc_create_empty(filename) %by using the command length(lat_variable) it shows an error! nc_add_dimension(filename,'points',npoints) varstruct.Name='stormid'; varstruct.Nctype=nc_double; varstruct.Dimension={'points'}; nc_addvar(filename,varstruct) nc_attput(filename,'stormid','units','lp') nc_attput(filename, 'stormid', 'standard_name', 'storm_id') varstruct.Name='rmd'; varstruct.Nctype=nc_double; varstruct.Dimension={'points'}; nc_addvar(filename,varstruct) nc_attput(filename,'rmd','units','date') nc_attput(filename, 'rmd', 'standard_name', 'rmd') varstruct.Name='gm'; varstruct.Nctype=nc_double; varstruct.Dimension={'points'}; nc_addvar(filename,varstruct) nc_attput(filename,'gm','units','time') nc_attput(filename, 'gm', 'standard_name', 'gm') varstruct.Name='windspd'; varstruct.Nctype=nc_double; varstruct.Dimension={'points'}; nc_addvar(filename,varstruct) nc_attput(filename,'windspd','units','kmh') nc_attput(filename, 'windspd', 'standard_name', 'windspd') varstruct.Name='windir'; varstruct.Nctype=nc_double; varstruct.Dimension={'points'}; nc_addvar(filename,varstruct) nc_attput(filename,'windir','units','meters') nc_attput(filename, 'windir', 'standard_name', 'windir') %nc_add_dimension(filename,'z92',length(elev)) %varstruct.Name='elevation'; %varstruct.Nctype=nc_double; %varstruct.Dimension={'points'}; %nc_addvar(filename,varstruct) %nc_attput(filename,'elevation','units','m') % there is an error here too!nc_attput(filename,'title','Converting bathymetry data to NETcdf file') %nc_varput(filename, 'elevation', elev) nc_varput(filename, 'stormid', stormid) nc_varput(filename, 'rmd', rmd) nc_varput(filename, 'z92', z92) nc_varput(filename, 'x84', x84) nc_varput(filename, 'y84', y84) nc_varput(filename, 'z84', z84) stormid=dataset(:,1); rmd=dataset(:,2); gm=dataset(:,3); windspd=dataset(:,4); windir=dataset(:,5); nc_dump(filename)