batch
Run MATLAB script or function on worker
Syntax
Description
runs
the script file j
= batch(script
)script
on a worker in the cluster specified by the
default cluster profile. (Note: Do not include the .m
file extension with
the script name.) The function returns j
, a handle to the job object that
runs the script. The script file script
is copied to the worker.
By default, workspace variables are copied from the client to workers when you run
batch(script)
. Job and task objects are not copied to workers.
runs j
= batch(expression
)expression
as an expression on a worker in the cluster specified
by the default cluster profile. The function returns j
, a handle to the
job object that runs the expression.
By default, workspace variables are copied from the client to workers when you run
batch(expression)
. Job and task objects are not copied to
workers.
is identical to j
= batch(myCluster
,expression
)batch(expression)
except that the expression runs on a
worker in the cluster specified by the cluster object myCluster
.
runs the function j
= batch(fcn
,N
,{x1,...,xn}
)fcn
on a worker in the cluster specified by the default
cluster profile. The function returns j
, a handle to the job object that
runs the function. The function is evaluated with the given arguments,
x1,...,xn
, and returns N
output arguments. The
function file for fcn
is copied to the worker. (Note: Do not include the
.m
file extension with the function name argument.)
is identical to j
= batch(myCluster
,fcn
,N
,{x1,...,xn}
)batch(fcn,N,{x1,...,xn})
except that the function runs on
a worker in the cluster specified by the cluster object myCluster
.
specifies options that modify the behavior of a job using one or more name-value arguments.
These options support batch for functions and scripts, unless otherwise indicated. Use this
syntax in addition to any of the input argument combinations in previous syntaxes.j
= batch(___,Name,Value
)
Examples
Input Arguments
Output Arguments
Tips
To view the status or track the progress of a batch job, use the Job Monitor, as described in Job Monitor. You can also use the Job Monitor to retrieve a job object for a batch job that was created in a different session, or for a batch job that was created without returning a job object from the
batch
call.Delete any batch jobs you no longer need to avoid consuming cluster storage resources unnecessarily.
To develop and test your code, you can run batch job on a local cluster on your client machine. If you close your MATLAB session, any batch jobs using the local cluster also stop immediately.
When you offload work to a remote cluster, you can close the MATLAB client session while the job is processing and retrieve information from a batch job later or in a new client session.