Saving cell to file to save RAM
1 次查看(过去 30 天)
显示 更早的评论
I am trying to run this code to give me my values in a cell, however i am dealing with a large amount of data and it usually crashes around the 6th iteration of j. I was wondering is there any way i can optimise this or save to file line by line to save RAM. I am very new to matlab so any help is appreciated.
j = 1;
while j <= 4
%inputdir = 'C:\Users\jorda\Desktop\Physics Project\Country PM25';
%outputfile = 'Africa_With_Dust'; %do not put it into inputdir !
%dinfo = dir( fullfile(inputdir, '*.mat') );
%filenames = fullfile( inputdir, {dinfo.name} );
PM_val = ncread(With_Dust_List(j),'PM25');
i = 1;
j = j + 1;
while i <= 51
mat_zer=zeros(2600,7200);
isin1 = inpolygon(LON,LAT,S(i).X,S(i).Y);
mat_zer(isin1)=st(i);
[row1,col1] = find(mat_zer~=0);
mat_zer_pm = PM_val;
inds1 = sub2ind(size(mat_zer_pm),row1,col1);
new_mat1 = nan(size(mat_zer_pm));
new_mat1(inds1) = mat_zer_pm(inds1);
Country_With{i,j} = new_mat1;
i = i + 1;
end
%for K = 1 : length(filenames)
%thisfile = load(filenames{K});
%save(outfile, '-struct', 'Country_With{1:51,j-1}', '-append');
%end
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!