ARRY EXEEDS RANDOM NUMBER

조회 수: 2 (최근 30일)
george veropoulos
george veropoulos 2021년 8월 18일
댓글: george veropoulos 2021년 8월 21일
hi i receive this message in matlab when i run a monte carlo probllem
Requested 1000000x10000 (74.5GB) array exceeds maximum array
size preference. Creation of arrays greater than this limit
may take a long time and cause MATLAB to become
unresponsive. See array size limit or preference panel for
more information.
Error in Z12R2the (line 14)
y=0.5.*(yv-yh)+0.5.*(yv+yh).*cos(2.*PSI);
Error in impedance_antennaR_new_2d (line 82)
fn=Z12R2the(r,PSI);
i can change this preference? i want to run the MC with 1e6 randon mumbers
thank you
George
  댓글 수: 2
David Hill
David Hill 2021년 8월 18일
There are various ways around a size limit. Why not loop through a number of times? Additional code would be helpful to make suggestions.
george veropoulos
george veropoulos 2021년 8월 19일
Hi i use the following line
n=1e5;
PSI=random('unif',psi1,psi2,[1,n]);
pd = makedist('Normal', 'mu', h0, 'sigma', st);
t = truncate(pd,h1,h2);
r = random(t,1e4,1);
when i change the tandom numbers form 1e4 -> 1e5 i receive the message about memory
George

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2021년 8월 19일
PSI=random('unif',psi1,psi2,[1,n]);
That is a row vector
r = random(t,1e4,1);
That is a column vector
fn=Z12R2the(r,PSI);
You are passing in the column vector and the row vector
y=0.5.*(yv-yh)+0.5.*(yv+yh).*cos(2.*PSI);
The 2.*PSI part will be the row vector.
Without seeing more code, we cannot be certain, but the implication is that most likely yv and yv are a column vector the size of r.
When you try to combine a column vector with 1e5 elements, with a row vector with 1e4 elements, that is generally legal in MATLAB, and MATLAB would try to create a 1e5 x 1e4 array that contained all combinations -- like
r1c1 r1c2 r1c3 r1c4 .... r1c10000
r2c1 r2c2 r2c3 r2c4 .... r2c10000
...
r100000c1 .............. r100000c10000
That would require 1e5 * 1e4 * 8 bytes, which is almost certainly a lot more than you have on your system.
If you did manage to create an array that size, then MATLAB would immediately need to create another array that size in order to finish the addition part of the assignment.
If you have enough free space, it is probably possible to configure your MATLAB and your operating system to permit MATLAB to go ahead and create arrays that large. However, the resulting operations would be quite slow, as it would write a lot of information to disk.
As your variables are random, it is unlikely that you need to have all of those in memory at one time. You would be better off running with 1e4 r values and accumulating statistics for 10 of those runs.
  댓글 수: 5
george veropoulos
george veropoulos 2021년 8월 20일
YES work with 1e6 random number !!
george veropoulos
george veropoulos 2021년 8월 21일
i change the column vector with column and the code is runing with 1e6 random number
thank !

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2021년 8월 19일
If you request 74.5GB of RAM for a matrix, care for having this size of memory plus some head room. On a 160 GB RAM machine, the code will run.
Did you follow the advice in the error message already:
See array size limit or preference panel for more information.
?
  댓글 수: 5
Walter Roberson
Walter Roberson 2021년 8월 19일
Divide the run up into batches that each fit into memory, and accumulate statistics as necessary.
george veropoulos
george veropoulos 2021년 8월 19일
I dont know how can i make this

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by