- Pre-process entries so as to make them all of equal size: For entries corresponding to non- 'leap years', save the 60th entry (for February 29) as NaN (not-a-number). The subsequent entries, starting from the 61st (for March 1) are therefore shifted by 1. The matlab function 'leapyear' can be used to perform checks for every instance in the loop ( https://www.mathworks.com/help/aerotbx/ug/leapyear.html ).
- To save data from matrices of unequal size without manipulating entries, cell arrays may be used. Find more information on indexing cell arrays and accessing data in this link: https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-cell-array.html
How to import multiple .nc files of different lengths
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Gemma
el 28 de Mzo. de 2017
Respondida: Eeshan Mitra
el 30 de Mzo. de 2017
Hello,
I'm trying to import 164 3-D files of size 192x94x365(6). The files contain gridded climate data and are stored annually.
I'm struggling to import these into a single, large, 4-D file due to the extended length of the leap year files. Matlab returns a dimension mismatch.
I have this:
year=[1851:2014];
for ii=1:164
clear fnpath0 fname0 fname1;
fnpath0 = 'myfilepath';
fname0 = sprintf('uwnd.10m.%d.nc',year(ii));
fname1 = [fnpath0 fname0];
Uwndorg = ncread(fname1,'uwnd');
Uwndall(22:60,30:59,:,ii)=Uwndorg(22:60,30:59,:);
end
0 comentarios
Respuesta aceptada
Eeshan Mitra
el 30 de Mzo. de 2017
Depending on the application, and how you want to process the data subsequently, data from matrices of unequal size may be saved using one of the two methods:
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Variables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!