SGbatchjob

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 4.8, Creation date: 2019-12-07, Last change: 2025-09-14

creates a job from a string using matlab's batch command and

Description

This function is useful if very large functions should be executed in the background

batch('SGG=SGremsurfedgepoints(SG)'); jj=ans; load (jj,'SGG'); SGfigure(SGG);


See Also: , SGbatchresult , stringfnctresult , SGbatchdelete

Example Illustration

 missing image of SGbatchjob(cmd)

Syntax

job=SGbatchjob(cmd)

Input Parameter

cmd: matlab command to execute as parallel job

Output Parameter

job: parallel job

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

Output Results

Algorithm Steps

  1. Initialize a global variable SGBatchIDtable which is used to keep track of batch jobs.
  2. Determine the number of existing entries in SGBatchIDtable using size(SGBatchIDtable,1).
  3. Iterate over each entry in SGBatchIDtable to check if the command cmd is already in the batch job list.
  4. 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.
  5. If the command is not found, a new batch job is started using batch(cmd).
  6. 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