how to deal with the array size limits problem?

I built a zero arra using "I=zeros(80,80,400,400,700);"
But the commamd window said
" The requested 80x80x400x400x700 (5340.6GB array exceeds the preset maximum array size. Creating arrays larger than this limit can take a long time and cause matlab to be unresponsive. For more information, see array size limits or presets panel"
What dose it mean?And how to deal with it?

Answers (1)

You're asking for roughly 5 terabytes of contiguous memory. To put that into some context, in 2012 the English Wikipedia had about 1.9 terabytes of multimedia files.
If your machine has enough memory to create such a large array you can uncheck the preference to limit the amount of memory / size of the array that MATLAB will try to allocate. However, allocating that large a chunk of memory is likely to take a long time and doing anything with that data may require a second large chunk of memory.
Consider if you actually need to create that huge an array. If you describe what you're trying to do we may be able to suggest an alternate approach that requires less memory (or perhaps multiple smaller chunks that take up the same total amount of space.)

4 Comments

Thanks a lot for your answer.
I click the Accept this answer button,but it always reports error.And I have refreshed the web for a few times ,but it still has no work.
And back to my problem.
The first piece of the following code is that I coded at the beginning.
% No.1
fs=5e7;%sampling freq
[yS,xS]=meshgrid((0.5e-3:0.5e-3:40e-3),(0.5e-3:0.5e-3:40e-3));
[pixel_Y,pixel_X,pixel_Z]=meshgrid(400,400,700);
FL=zeros(80,80,400,400,700);
for i=1:80
for j=1:80
FL(j,i,:,:,:)=2.*(sqrt((pixel_X-xS(j,i)).^2+(pixel_Y-yS(j,i)).^2+pixel_Z.^2))./6300;
end
end
I=zeros(400,400,700);
for i=1:80
for j=1:80
F=round(FL(i,j,:,:,:)*fs+1);
F1=squeeze(F);
A_scan=hilbert(squeeze(saft(j,i,:))); % saft is a 80×80×2500 array.
I=I+A_scan(F1)
end
end
But the FL=zeros(80,80,400,400,700) can't be built because of the array size limits and memory.
So,I changed my code to the following ,the second piece.
% NO.2
fs=5e7;%sampling freq
[yS,xS]=meshgrid((0.5e-3:0.5e-3:40e-3),(0.5e-3:0.5e-3:40e-3));
[pixel_Y,pixel_X,pixel_Z]=meshgrid(400,400,700);
tic;
focalLaw=zeros(400,400,700);
I=zeros(400,400,700);
for j=1:80
for i=1:80
FL=2.*(sqrt((pixel_X-xS(i,j)).^2+(pixel_Y-yS(i,j)).^2+pixel_Z.^2))./6300;
F=round(FL.*fs+1);
A_scan=hilbert(squeeze(saft(j,i,:))); % saft is a 80×80×2500 array.
I=I+A_scan(F);
end
end
toc;
Then it can run. But it has a new problem that it took more than 16000s ,almost 5 hours,to compute.Is there anyway to accelerate computing?
Please explain in words not code what you're trying to do with this code and we may be able to offer some suggestions.
What I do is 3D-synthetic aperture focusing technique(3D-SAFT) in Ultrasonic .
There are several steps below.
1.Capturing the amplitude of the ultrasonic A-Sacn signal of every excitation source.
2.Seting the parameters,such as sampling frequency,ultrasonic wave speed,imaging area ,excitation source position and so on.
3.Deviding the 3D area into several meshes.
4.Computing the time-delay from every mesh to every excitation source position.
5.Extracting corresponding amplitude of every mesh from amplitude matrix using time-delay and sampling frequency ,and then superimpositting the amplitude.
6.Visualizing the 3D focusing data

Sign in to comment.

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Tags

Asked:

on 24 Jun 2021

Commented:

on 28 Jun 2021

Community Treasure Hunt

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

Start Hunting!