Is it possible to use pctRunOnAll as a batch?

2 views (last 30 days)
Bobby Brown
Bobby Brown on 18 Jul 2016
Answered: Edric Ellis on 18 Jul 2016
Hi,
I have a script that will only allow me to parallel it if i use pctRunOnAll because it uses a simulation plugin that only likes one instantiation and does not like parfor. As a pctRunONAll, it works fine.
I want to get this parallel work to operate in a batch in the background. Is it possible to combine pctRunOnAll with a batch?
Am i able to do this?
j = batch(pctRunOnAll 'script1', 'matlabpool', 10, 'CaptureDiary', true);
Thanks Bobby

Answers (1)

Edric Ellis
Edric Ellis on 18 Jul 2016
While you can use pctRunOnAll with batch, it's a little awkward. Here's what you need to do:
j = batch(@pctRunOnAll, 0, {'script1'}, 'Pool', 10, 'CaptureDiary', true)
Here we're using the form of batch which takes a function handle - in this case @pctRunOnAll. Then, we must specify the number of output arguments from that function - which is 0, and then the input arguments as a cell array, {'script1'}.
One other option you might wish to explore is wrapping up your task inside a function, and then you can use parfeval to run multiple iterations. This is also compatible with batch.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!