User`s guide
1 Getting Started
1-8
Run a Batch Job
To offload work from your MATLAB session to run in the background in another session,
you can use the batch command. This example uses the for-loop from the previous
example, inside a script.
1
To create the script, type:
edit mywave
2
In the MATLAB Editor, enter the text of the for-loop:
for i = 1:1024
A(i) = sin(i*2*pi/1024);
end
3
Save the file and close the Editor.
4
Use the batch command in the MATLAB Command Window to run your script on a
separate MATLAB worker:
job = batch('mywave')
MATLAB
®
client
MATLAB
®
worker
batch
5
The batch command does not block MATLAB, so you must wait for the job to finish
before you can retrieve and view its results:
wait(job)
6
The load command transfers variables created on the worker to the client
workspace, where you can view the results:
load(job,'A')
plot(A)
7
When the job is complete, permanently delete its data and remove its reference from
the workspace:
delete(job)
clear job