So the way to use MATLAB is to use a shell script that will set the environment variable correctly, then invoke MATLAB with a numerical argument. Read the rest of the hint for an example...
- Create a shell script called matlabfoo.sh:
As you see, you have to make sure you call MATLAB with the nojvm argument, or else it will complain about not being the console user. The -r argument lets you specify a function to run. In this example, the shell variable X is used to pass a different input argument, based on what Xfeed supplies from the range agument.#!/bin/sh # For some reason, MATLAB dies if you don't have # HOME set in environment export HOME=/home/username X="foo(${1})" /Applications/MATLAB7/bin/matlab -nojvm -nodisplay -r $X ; - Create a MATLAB function called foo (foo.m):
function foo(in) try disp(['in was: ',num2str(in)]) % Now do something A = [(in-1)*10+1:(in*10)]; disp(A) catch disp('Something went wrong') disp(lasterr) end % It is critical that your task ends with "exit" exit - Put these in a directory called matlab_test
- Create a directory to store results called matlab_out
- Launch Xgrid, then choose the Xfeed plugin. Give it the following arguments (final settings screenshot):
- Command: /bin/sh
- Argument 1: Literal matlabfoo.sh
- Argument 2: Range From: 1 to: 16 by: 1
- Source: /path/to/matlab_test
- Destination: /path/to/matlab_out
< M A T L A B >
Copyright 1984-2004 The MathWorks, Inc.
Version 7.0.0.19901 (R14)
May 06, 2004
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
in was: 5
41 42 43 44 45 46 47 48 49 50
[robg adds: I haven't tested this one.]

