Compiling Matlab Code: it works in Matlab but not when compiled.

1 vue (au cours des 30 derniers jours)
Doriana
Doriana le 16 Mai 2014
Commenté : Doriana le 19 Mai 2014
Hello all,
I have a program that use parallel toolbox. That works perfectly in Matlab but when I compile it and execute it, I get this error: Error using parpool. Allowed value for the second argument is an integer specifying the pool size.
the program crashes in this row:
parpool('local' ,poolsize);
To run the program outside matlab I insert as a parameter :
'poolsize' '2'
Thank you,
P.s i'm using matlab (2014a) and mcr 8.3 (2014a)

Réponse acceptée

Harsheel
Harsheel le 16 Mai 2014
Not sure how you're 'inserting' the parameter but seems like you're passing the arguments from command line. If so then, all arguments are passed in as characters. You need to convert it to integer and then pass it to parpool. Like:
if ischar(poolSize) %where poolSize stores the user input
poolSize=str2num(poolSize); %convert string to number
end
parpool('local',poolSize);
  1 commentaire
Doriana
Doriana le 19 Mai 2014
Thank you Harsheel, the program works correctly.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Parallel Computing Fundamentals 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!

Translated by