Error sending data to .xlsx (NetCDF)
Afficher commentaires plus anciens
I have the CHIRPS data plus these scripts and at the time the data is sent to the .xlsx it has errors in the dates and the precipitation data is blank.
the biggest problem is the years, months and days
Does anyone have an idea to solve?
download link:
https://data.chc.ucsb.edu/products/CHIRPS-2.0/global_daily/netcdf/p25/
the functions used are attached (get_and_save_ncf_data.m license.txt testfun.m natsortfiles_test.m natsort.m natsortfiles.m natsortfiles_doc.m)
%% Long and Lat
LG=[-48.375]; % longitude
LT=[-1.125]; % latitude
%% main code
fileDir = pwd; % current directory (or specify which one is the working directory)
S = dir(fullfile(fileDir,'*.nc')); % get list of nc files in directory
S = natsortfiles(S); % sort file names into natural order , see :
%(https://fr.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filename-sort)
for k = 1:length(S)
filename = S(k).name % to actually show filenames are sorted (see command window)
sheet = 1; % for excel file output, either on first sheet or increment sheet number if needed
filename_out = [filename(1:length(filename)-3) '.xlsx']; % replace nc extension with xlsx (or whatever you want)
get_and_save_ncf_data(fullfile(fileDir, filename),LG,LT,fullfile(fileDir, filename_out),sheet);
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur NetCDF dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!