Error using meshgrid function.

19 ビュー (過去 30 日間)
VIJENDRA
VIJENDRA 2014 年 10 月 9 日
コメント済み: VIJENDRA 2014 年 10 月 10 日
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!
  1 件のコメント
VIJENDRA
VIJENDRA 2014 年 10 月 10 日
Thank you Andrew Reibold, its very good description.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel Computing Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by