Use of parfor to reduce computational time
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Walter Roberson
le 28 Août 2019
Because you can calculate the ode analytically you can calculate the value you need instead of looping to find it.
Walter Roberson
le 29 Août 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
Réponses (0)
Voir également
Catégories
En savoir plus sur Parallel for-Loops (parfor) dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!