For more information about Matlab please see the
matlab application page.
Using Matlab in Batch processing mode.
Get Source Code
First you need to create your source code.
$ cp -rv /share/apps/samples/matlab-batch ./
$ cd matlab-batch
Matlab code does not need to be compiled before running.
See example matlabex.m below:
% Durer's matrix
A = [16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1]
% sum the columns of A
sum_of_columns = sum(A)
% transpose A then transpose the sum of the transpose
% to give the sums of the rows of A
A_transpose = A'
sum_of_rows = sum(A')'
% find the diagonal of A and it's sum
diagonal_of_A = diag(A)
sum_of_diag_A =sum(diag(A))
Write the jobfile
#PBS -N Matlab_example
#PBS -l nodes=1
#PBS -l walltime=00:15:00
#PBS -V
cd $PBS_O_WORKDIR
matlab -nojvm -nosplash -nodisplay < matlabex.m
This will send the output to Matlab_example.o###.
If you would like to send it somewhere else, like myfile.txt,
add > myfile.txt to the end of the last line.
The -nojvm flag disables the Java Virtual Machine, -nosplash flag starts matlab without displaying the splash screen.
Submit the Job
$ qsub job_file_name
Output
job_file_name.o####
< M A T L A B >
Copyright 1984-2006 The MathWorks, Inc.
Version 7.3.0.298 (R2006b)
August 03, 2006
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
>> >>
A =
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
>> >> >>
sum_of_columns =
34 34 34 34
>> >> >> >>
A_transpose =
16 5 9 4
3 10 6 15
2 11 7 14
13 8 12 1
>>
sum_of_rows =
34
34
34
34
>> >> >>
diagonal_of_A =
16
10
7
1
>>
sum_of_diag_A =
34
>> >> >> >> >> >>
Errors
If the output is not what you expected check the job_file_name.e#### file.