Help with resolving out of memory

I have a function generatin a value (Vehicle) and ID numbers (VID) for vehicles.
function[Vehicle,VID]=race(ID, HHPerson,nBEV,BEV,x,i2)
for j = 1:nBEV
if HHPerson(i2)>=x
for k=1:nBEV
%There is only one car if
if k==j
Vehicle{j,k}=BEV(:, j);
VID{j,k}=ID(j);
else
Vehicle{j,k}=BEV(:, j)+BEV(:, k);
VID{j,k}=[ID(j) ID(k)];
end
end
end
if HHPerson(i2)<x
for k22=1:nBEV
%There is only one car if
Vehicle{j, k22} = BEV(:,k22);
VID{j, k22}= ID(k22);
end
end
end
end
The size of the cells are 108x108, In Vehicle, every cell contains a 525600x1 double and in VID, every cell contains one ore two numbers.
This is the error message:
Out of memory. Type HELP MEMORY for your options.
Error in race (line 11)
Vehicle{j,k}=BEV(:, j)+BEV(:, k);
Error in H2 (line 25)
[Vehicle1, VID1]=race(ID,HHPerson,nBEV,BEV,x,C);
Error in A1337 (line 212)
[GUD,GUDID]=H2(ID2,HHPerson,nBEV,BEV,x,Hcombos,Household,sample,A);
The initial size of the cells was 429x429, so I've already tried reducing the nr of vehicles included. Is there any way to circumvent the memory limit? The size of the cells is already preallocated as well and my memory is 64 GB

 Respuesta aceptada

Walter Roberson
Walter Roberson el 19 de Abr. de 2021
You should be preallocating the cell array Vehicle and VID as cell(nBEV,nBev}
The size of the cells are 108x108, In Vehicle, every cell contains a 525600x1 double
bytes_needed = 108 * 108 * 525600 * 8
bytes_needed = 4.9045e+10
gigabytes_needed = bytes_needed / 2^30
gigabytes_needed = 45.6765
You have problems unless you have more than 46 gigabytes.

3 comentarios

Joel Schelander
Joel Schelander el 19 de Abr. de 2021
I have 64 GB of memory.
Joel Schelander
Joel Schelander el 19 de Abr. de 2021
My function H2, generates Vehicle1 and Vehicle2 of this size. Are they taking up 91 GB then?
[Vehicle1, VID1]=race(ID,HHPerson,nBEV,BEV,x,C);
[Vehicle2, VID2]=race(ID,HHPerson,nBEV,BEV,x,C);
Walter Roberson
Walter Roberson el 19 de Abr. de 2021
Probably yes, 91+ gigabytes for two such arrays.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Aerospace Blockset en Centro de ayuda y File Exchange.

Productos

Versión

R2017b

Etiquetas

Preguntada:

el 19 de Abr. de 2021

Comentada:

el 19 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by