Error using meshgrid function.

16 次查看(过去 30 天)
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 个评论
Andrew Reibold
Andrew Reibold 2014-10-9
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 2014-10-9
You may not need to use meshgrid.
What are you calculating or plotting?

请先登录,再进行评论。

采纳的回答

Andrew Reibold
Andrew Reibold 2014-10-9
编辑:Andrew Reibold 2014-10-9
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!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel Computing Fundamentals 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by