Error using meshgrid function.

19 vues (au cours des 30 derniers jours)
VIJENDRA
VIJENDRA le 9 Oct 2014
Commenté : VIJENDRA le 10 Oct 2014
I have 2 matrices 'A' and 'B' both of size 500*500. when i am trying to create meshgrid using
[X1,Y1] = meshgrid(A,B);
this shwo error "Out of memory. Type HELP MEMORY for your options. Error in meshgrid (line 58) xx = xrow(ones(size(ycol)),:);"
Can anyone tell why is it happening? Is there any size limit for the variable?
  2 commentaires
Andrew Reibold
Andrew Reibold le 9 Oct 2014
I get the same thing with 500x500, but it works ok for 100x100
The bottom line, is that to do that exactly as written you will need a bigger toaster.
Star Strider
Star Strider le 9 Oct 2014
You may not need to use meshgrid.
What are you calculating or plotting?

Connectez-vous pour commenter.

Réponse acceptée

Andrew Reibold
Andrew Reibold le 9 Oct 2014
Modifié(e) : Andrew Reibold le 9 Oct 2014
The reason is this.
Lets say I make two 500x500 matrices using the following.
A = ones(500,500);
B = 4*ones(500,500);
Lets look at how big one of those is
whos A
Name Size Bytes Class Attributes
A 500x500 2000000 double
2,000,000 Bytes is 2 Megabytes.
Now to run meshgrid, the grid vector A is replicated numel(B) times to form the columns of X
How many times is that?
numel(B)
ans =
250000
2BM * 250,000 is the same as 500GB
Do you have 500GB available?
You can check using memory. Here is an example
memory
Maximum possible array: 89643 MB (9.400e+10 bytes) *
Memory available for all arrays: 89643 MB (9.400e+10 bytes) *
Memory used by MATLAB: 3493 MB (3.663e+09 bytes)
Physical Memory (RAM): 16308 MB (1.710e+10 bytes)
Here I can see that I only have enough space for about 90GB of array space when for this process I will need 500GB. This means I result in the same error as you.
meshgrid(A,B)
Error using repmat
Out of memory. Type HELP MEMORY for your options.
Error in meshgrid (line 58)
xx = repmat(xrow,size(ycol));
And that is why you are having your problem! Not enough memory available on your computer. You will need to try to split the problem up or perhaps lower grid resolution if possible.
I hope this explanation answered your question, good luck!
  1 commentaire
VIJENDRA
VIJENDRA le 10 Oct 2014
Thank you Andrew Reibold, its very good description.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Parallel Computing Fundamentals dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by