Borrar filtros
Borrar filtros

Use of parfor to reduce computational time

1 visualización (últimos 30 días)
Anil Rajajapantulu
Anil Rajajapantulu el 28 de Ag. de 2019
Comentada: Walter Roberson el 29 de Ag. de 2019
I have a function with 100000 element array and i want to use parfor loop to reduce computaional time. Here is the code
global allNucleiDrops;
if (~isempty(allNucleiDrops))
nMax = length(allNucleiDrops);
for nCount = 1:1:nMax
index = allNucleiDrops(nCount);
nMolecules = Type_3(index);
if (nMolecules > 1 )
tspan = [tInitial tFinal];
oldSize = pSize(index);
oldVol = nMolecules*pP.volumeOfMolecule;
conc = (nMolecules/c.NA)/dP.volume;
[t,N] = ode45(@(t,N) 4*pi*pP.diffusivity*c.NA*pP.volumeOfMolecule*conc*((3*oldVol)/(4*pi))^(1/3), tspan, oldVol);
tLenght = length(N(:,1));
for tCount = tLenght:-1:1
newVol = N(tCount);
newSize = newVol/pP.volumeOfMolecule;
changeMolecule = newSize-oldSize;
if (changeMolecule > 0)
if (changeMolecule <= nMolecules)
pSize(index) = newSize;
Type_3(index) = Type_3(index) - changeMolecule;
break;
end
end
end
clear N t;
end
end
end
  7 comentarios
Walter Roberson
Walter Roberson el 28 de Ag. de 2019
Because you can calculate the ode analytically you can calculate the value you need instead of looping to find it.
Walter Roberson
Walter Roberson el 29 de Ag. de 2019
newSize = oldSize at tFinal =
1/12*(2*Pi^(2/3)*oldVol^(1/3)*conc*6^(1/3)*pP^2*diffusivity*c*NA*
volumeOfMolecule*tInitial+oldSize*pP.volumeOfMolecule-oldVol)*6^(2/3)/Pi^(2/3)/
oldVol^(1/3)/conc/pP^2/diffusivity/c/NA/volumeOfMolecule

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Parallel for-Loops (parfor) en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by