Syntax
job=SGbatchjob(cmd)
Input Parameter
cmd : | | matlab command to execute as parallel job |
Output Parameter
Examples
SGbatchdelete
job=SGbatchjob('VMreadnifti(''/Volumes/LUETH-WIN/WIN AIM Matlab Libraries/Medical Data/004MITK - Klinikum Sud/004Lumbal vertebral body 1.nii'');');
job=SGbatchjob('[rand(1e3,1e3)*rand(1e3,1e3)]');
wait(job) % Not required
SGbatchresult(job); whos ans
Copyright 2019-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This algorithm is designed to execute large MATLAB functions in the background using the batch command. It is part of the SolidGeometry library and is useful for parallel processing.
Input Parameters
- cmd: A MATLAB command provided as a string that is intended to be executed as a parallel job.
Output Results
- job: The parallel job object created by the batch command.
Algorithm Steps
- Initialize a global variable
SGBatchIDtable
which is used to keep track of batch jobs.
- Determine the number of existing entries in
SGBatchIDtable
using size(SGBatchIDtable,1)
.
- Iterate over each entry in
SGBatchIDtable
to check if the command cmd
is already in the batch job list.
- If the command is found in the list, an error is raised indicating that the command is already in the batch job list and suggests using
SGbatchresult
before restarting the job.
- If the command is not found, a new batch job is started using
batch(cmd)
.
- Update
SGBatchIDtable
with the new job's ID, the command, and the job object itself.
Example Usage
The function can be used to execute a command in the background, such as reading a NIfTI file or performing matrix operations. After starting the job, the user can wait for its completion and retrieve the results using SGbatchresult
.
Algorithm explaination created using ChatGPT on 2025-08-19 08:22. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21