#!/bin/csh # this script is a companion script for submitmjobs for MATLAB apps # it demonstrates how the passed "task" can be used to make each of # the ntasks to perform a different task or use different data. If your # app is a function m-file, "task" needs to be passed as input argument. # If your app is a script m-file, "task" is automatically available # because it shares the same workspace as myscript. # Use one form or the other. #$ -j y #$ -m ae # IMPORTANT: DONOT indent any of the below statements matlab -singleCompThread -nodisplay << MATLAB_ENV % The below works like a script m-file between MATLAB_ENVs [ierr, task] = unix('printenv MATLAB_TASK'); if ierr % ierr=1 if MATLAB_TASK not exist n = 1000; % task not defined; you must have used qsub to get here else task = str2double(task); % you must have used submitmjobs n = task * 1000; % define n with task end myExample(n) % parfor i=1:n exit % don't forget to exit MATLAB MATLAB_ENV # keep this line to ensure newline