Green Grid Project
Project Home
Project Background
MDS Data
Presentations
Downloads

Campus Grid Resources
grid-mapfile
Dartmouth CA
fMRIDC Grid
CGL Discovery Cluster




Application Notes :: Matlab on the Grid




Submit/Shell Script

#!/bin/sh

echo "-------------------------------------------------------------------"
echo "Starting job at `date` on host `hostname`"

#
# matlab_hello is a in a file called 'matlab_hello.m'
#

HDIR="/afs/dbic.dartmouth.edu/usr/gazzaniga/jed/Grid/examples/matlab"

# Copy from AFS to local storage
cp ${HDIR}/matlab_hello.m .

# Execute Matlab
/afs/dbic.dartmouth.edu/usr/local/common/bin/matlab -r matlab_hello

# Transfer results back to AFS
cp wave.ps ${HDIR}

# remove 'M-file' when finished
rm matlab_hello.m wave.ps

echo "Exit Status: $?"
echo "Finished job at `date` on host `hostname`"
echo "-------------------------------------------------------------------"
     
matlab_hello.sh


Sample Matlab 'M-File'

%
% a matlab example script
%

fprintf('creating plot...\n');

% create some data
time=[0:.1:20];
wave=10*sin(2*pi*2*time);

% matlab 6.5 bug -- call figure, close then print
figure;close

% Create a Plot of wave
plot(wave)

% Print using the PostScript driver to wave.ps
print -dps wave

% make sure your script calls exit
exit



     
matlab_hello.m


Output

[jed@purkinje] ~/Grid > globus-job-run cs-01.grid -stage matlab_hello.sh
-------------------------------------------------------------------
Starting job at Mon Sep 27 10:13:54 EDT 2004 on host cs-01.grid.dartmouth.edu
Warning: X does not support locale C.

                              < M A T L A B >
                  Copyright 1984-2002 The MathWorks, Inc.
                      Version 6.5.0.180913a Release 13
                                Jun 18 2002


  To get started, type one of these: helpwin, helpdesk, or demo.
  For product information, visit www.mathworks.com.

creating plot...
Exit Status: 0
Finished job at Mon Sep 27 10:13:55 EDT 2004 on host cs-01.grid.dartmouth.edu
-------------------------------------------------------------------

     
Output
$Id: application_matlab.php,v 1.1 2004/09/28 15:57:03 jed Exp jed $