[collapsible heading="Alternative to the Compact MATLAB Launcher: matlab  -r  " . . . "" elem="h4"]As demonstrated in the pbatch batch script, the MATLAB command spaces (i.e., between double quotes) — while compact — is quite limiting
#!/bin/csh
# set default to 4 cores unless override with, say, qsub -pe omp 8
#$ -pe omp 4
# add more qsub options here (start with #$)
matlab -nodisplay -r "matlabpool open 4, s=0; parfor i=1:n, s=s+i; end, matlabpool close, s, exit"
An alternative form factor is available
scc1$ qsub -pe omp 8 ./pbatch_l
pbatch_l:
#!/bin/csh
# set default to 4 cores unless override with, say, qsub -pe omp 8
#$ -pe omp 4
# add more qsub options here (start with #$)
matlab -nodisplay << MATLAB_ENV
% The below works like a script m-file between MATLAB_ENVs
% Better to use environment variable to pick up the runtime core size
matlabpool open $NSLOTS
s = 0;        % initialize
parfor i=1:n  % Parallel Computing Toolbox's for-loop
  s = s + i;  % compute arithmetic sequence sum s
end
matlabpool close
s             % print
% you can also invoke your own function- or script- m-files
exit          % essential to include this
MATLAB_ENV
[/collapsible]