ARRY EXEEDS RANDOM NUMBER
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
george veropoulos
el 18 de Ag. de 2021
Comentada: george veropoulos
el 21 de Ag. de 2021
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 comentarios
David Hill
el 18 de Ag. de 2021
There are various ways around a size limit. Why not loop through a number of times? Additional code would be helpful to make suggestions.
Respuesta aceptada
Walter Roberson
el 19 de Ag. de 2021
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 comentarios
Más respuestas (1)
Jan
el 19 de Ag. de 2021
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 comentarios
Walter Roberson
el 19 de Ag. de 2021
Divide the run up into batches that each fit into memory, and accumulate statistics as necessary.
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!