read multiple netcdf files

1 回表示 (過去 30 日間)
YH
YH 2018 年 12 月 12 日
編集済み: Jan 2018 年 12 月 12 日
Hallo,
I have 54 net cdf files, which I need to read in matlab. they contain 4 variables
I tried the code below but it always reads until the 7th file then gives me '' Out of memory error''
I tried to fix the problem by setting the java head memory to the max, but that did not help.
Can someone help with that?
% my code
vars_to_load = {'lat', 'lon', 'series', 'time'};
projectdir = 'location of the data';
info = dir( fullfile(projectdir, '*.nc') );
n_files = length(info);
filenames = fullfile( projectdir, {info.name} );
lat = cell(n_files,1);
lon = cell(n_files,1);
series = cell(n_files, 1);
time= cell(n_files,1);
for k = 1 : n_files
f = filenames{K};
lat{k} = ncread(f, vars_to_load{1});
lon{k} = ncread(f, vars_to_load{2});
series{k} = ncread(f, vars_to_load{3});
time{k} = ncread(f, vars_to_load{4});
end
  2 件のコメント
KSSV
KSSV 2018 年 12 月 12 日
YOu are keep on piling/ adding the data...so obisously going out of memory....why you want to load entire data into workspace?
YH
YH 2018 年 12 月 12 日
編集済み: Jan 2018 年 12 月 12 日
I need the entire dataset so to get timeseries of 54 years. each file represents timeseries (hourly time series) for one year. the whole dataset is required for further editing.

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2018 年 12 月 12 日
If ncread is not a Java method, increasing the heap memory of Java decreases the memory available for Matlab, so I assume this is couterproductive. Try to reduce the Java heap size instead, close other application, install more RAM, increase the virtual memory, clear unused huge variables, install even more RAM and use a 64 bit version of Matlab (2015b was the last version, which existed in a 32 bit version also, so all newer versions are 64 bit).

カテゴリ

Help Center および File ExchangeNetCDF についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by