Out of memory. Type HELP MEMORY for your options.

3 views (last 30 days)
Hi, Please find below code.It gives Out of memory. HELP MEMORY for your options.Error in val = ltln2val(double(map),mapref,lats,longs,'bilinear'); . Please help me resolving this.
if true
% code
end
cd cards;
[Z_UP, R_UP] = geotiffread('srtm_49_01.tif');
[Z_DOWN, R_DOWN] = geotiffread('srtm_49_02.tif');
GRID_SIZE=size(Z_UP,1);
map=[Z_UP;Z_DOWN];
mapref=R_UP;
if GRID_SIZE==6000
mapref.RasterSize=[12000 6000];
mapref.LatitudeLimits=[50 60];
mapref.LongitudeLimits=[60 65];
else
mapref.RasterSize=[12002 6001];
mapref.LatitudeLimits=[50 60];
mapref.LongitudeLimits=[60 65];
end
lat1=54.99889;
lon1=60.37778;
lat2=55.12726;
lon2=60.57104;
ERinMeter=6371000;
distInMeters=distance(lat1,lon1,lat2,lon2,ERinMeter);
disc_number=distInMeters;
lats=linspace(lat1,lat2,disc_number);
longs=linspace(lon1,lon2,disc_number);
val = ltln2val(double(map),mapref,lats,longs,'bilinear');
dist=distance(lat1,lon1,lat2,lon2,'degrees');
dist=deg2km(dist)*1000;
dist=linspace(0,dist,disc_number);
X=dist;
Y=val;
figure
plot(X,Y,'-r');
Thanks, Mary

Answers (2)

Jan
Jan on 3 Aug 2015
The question to "out of memory" are as usual:
  1. Install more memory (twice as much is a good strategy)
  2. Because RAM is cheap even more memory is fine
  3. Stop other applications, which occupy memory
  4. Clear unused variables in Matlab
  5. Use smaller data types if possible (a double needs 8 bytes, a uint16 only 2)
  6. Use a 64-bit system and Matlab, such that you can use the bunch of gigabytes you have installed according to the points 1. and 2.
  7. Install more memoryYou find exactly the same answers, when you search in the forum for "Out of memory".

Kelly Kearney
Kelly Kearney on 3 Aug 2015
While the previous answers will resolve generic memory issues, I would first suggest seeing if you really need the memory-intensive part of your code. It looks like you're trying to interpolate values along a single line within a very large image, and the portion of the code that's causing errors is your attempt to convert the entire image to a double array. However, you don't need the entire image to accomplish your task, just the portion near the line itself. I suggest breaking the image into smaller subgrids and then only performing the interpolation using the subgrids near your line.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!