Can you do a parfor if Parallel Toobox is present else do a for
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
John Fox
le 29 Juin 2017
Commenté : Walter Roberson
le 30 Juin 2017
Is there a way: if the Parallel Toolbox is present then do the following loop with a parfor else use a for
I realize that ~isempty(which('parfor')) is true if the Parallel toolbox is present. I want to do:
if(~isempty(which('parfor')))
parfor j = 1:Lz
else
for j = 1:Lz
end
Next come the body of the loop.
Also I would like to do:
if(Lx <= 30000) % Small enough don't need parallel
for j = 1:Lz
else
parfor j = 1:Lz
end
Next comes the body of the loop.
Matlab complains "Illegal use of reserved keyword "else"."
0 commentaires
Réponse acceptée
Walter Roberson
le 29 Juin 2017
You do not need to do this. If you do not have the Parallel Computing Toolbox, parfor is automatically processed as a for loop.
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!