load - Load workspace variables from batch job - MATLAB (original) (raw)
Load workspace variables from batch job
Syntax
Description
load([j](#mw%5F88c092ac-b3c7-4244-950c-34396f800a68))
loads all variables from a batch job j
that ran a script or expression. The variables are assigned into the current workspace. If a variable in the current workspace exists with the same name, it is overwritten.
The workspace variables from a job are stored in the location given by theJobStorageLocation
property of the cluster that the job runs on. When you run load
, this data is not removed from theJobStorageLocation
. To remove the workspace data, use the delete function to remove individual tasks or entire jobs.
The load
function throws an error if:
- The
State
property of the jobj
is not'finished'
. - The
State
property of the jobj
is'finished'
and one of the tasks given by theTasks
property of the jobj
encountered an error.
Tip
To see if any of the tasks on the job j
failed after encountering an error, check if j.Tasks.Error
is empty. If the returned array is empty, none of the tasks on the job j
encountered any errors.
If some tasks completed successfully, you can use theOutputArguments
property of a task to access the output arguments of that task directly.
load([j](#mw%5F88c092ac-b3c7-4244-950c-34396f800a68),[variables](#mw%5F3fbbab18-36ac-4b5d-933b-c80d1ce5ada7))
loads variables from the job j
into the current workspace.
[S](#mw%5F2e8cf0df-23fb-4ee6-9a29-39b1b4eb223c) = load(___)
creates a structure containing variables from the job. For example, S = load(j)
loads all variables from the job j
into S
.
Examples
Run a batch job, then retrieve outputs from that job.
Assign the value 3
to the variable x
. Then, use batch
to create a job using the default cluster profile. In that job, run the expression 'y = magic(x)'
on a worker.
x = 3; j = batch('y = magic(x)');
When you create the job, the variable x
is automatically copied from the client workspace to the worker that runs the batch job.
Wait for the job to complete. Then, use load
to load the variables from the job into the client workspace.
The variables x
and y
are now available on the client. Display the values in y
.
Input Arguments
Names of variables to load, specified as one or more character vectors or string scalars.
variables
can be in one of the following forms.
Form of variables Input | Variables to Load |
---|---|
var1,...,varN | Load the listed variables, specified as individual character vectors or strings.Use the '*' wildcard to match patterns. |
'-regexp',expr1,...,exprN | Load only the variables or fields whose names match the regular expressions, specified as character vectors or strings. |
Example: load(j,'A*')
Example: load(j,'A','B*','C')
Example: load(j,'-regexp','^Mon',^Tues')
Output Arguments
Loaded variables, returned as a structure scalar.
Version History
Introduced in R2008a