prabu
prabu

Reputation: 141

How to solve memory issue in MATLAB - How to increase memory and max array length?

I have HDF files of Chlorophyll data. I am trying to process these HDF4 files to generate NDVI for the period. but when I try to execute

Band = hdfread('F:\MATLAB\HDF data\binned hdf\OCMHDFFiles_20-Sep-2012\O2_01APR2011_004_000_GAN_L3B_CL_M.hdf','clo','Fields','');
% Construct an RGB matrix from the three bands into one 3D matrix.
SPCrater_321 = cat(Band);
% Display the image
figure(1)
imshow(SPCrater_321)
xlabel('Longitude (pixels)')
ylabel('Latitude (pixels)')
title('ASTER Bands 3, 2, 1')
??? Error using ==> permute
Out of memory. Type HELP MEMORY for your options.
Error in ==> hdfsdsread at 57
data = permute(data,ndims(data):-1:1);
Error in ==> hdfread at 240
varargout{1} = hdfsdsread(hinfo,start,stride,edge);

Next execution is,

Band_3 = hdfread('F:\MATLAB\HDF data\binned hdf\OCMHDFFiles_20-Sep-2012\O2_01APR2011_004_000_GAN_L3B_CL_M.hdf','clo','Fields','ImageData3N');
Band_2 = hdfread('F:\MATLAB\HDF data\binned hdf\OCMHDFFiles_20-Sep-2012\O2_01APR2011_004_000_GAN_L3B_CL_M.hdf','clo','Fields','ImageData2');
Band_1 = hdfread('F:\MATLAB\HDF data\binned hdf\OCMHDFFiles_20-Sep-2012\O2_01APR2011_004_000_GAN_L3B_CL_M.hdf','clo','Fields','ImageData1');
% Calculate NDVI.
Band_2 = im2single(Band_2);
Band_3 = im2single(Band_3);
SPCrater_NDVI = (Band_3 - Band_2) ./ (Band_3 + Band_2);
% Display the image.
j=imresize(SPCrater_NDVI,0.5);
figure(5)
imshow(j,'DisplayRange',[0 1])
??? Out of memory. Type HELP MEMORY for your options.

And this is what I get when I type the 'memory' command at this point of execution:

memory
Maximum possible array:             255 MB (2.669e+008 bytes) *
Memory available for all arrays:    569 MB (5.971e+008 bytes) **
Memory used by MATLAB:             1197 MB (1.255e+009 bytes)
Physical Memory (RAM):             8181 MB (8.578e+009 bytes)
*  Limited by contiguous virtual address space available.
** Limited by virtual address space available.

can anyone please help me to solve this issue. how to increase the length of the memory array.

I really appreciate any help you can provide. I will be grateful if you can send me this information.

M. Prabu

(maprabu)

Upvotes: 2

Views: 9208

Answers (1)

user1284631
user1284631

Reputation: 4616

See this technote: http://www.mathworks.nl/help/matlab/matlab_prog/resolving-out-of-memory-errors.html?s_tid=doc_12b#brh72ex-52

The most straightforward solution is to go 64 bits.

Upvotes: 2

Related Questions