Hoffman2:Compiling MATLAB
Running the MATLAB GUI is not always desirable. If you already know that your code works and no visuals or user interaction are needed, then using the MATLAB GUI is unnecessary and adds extra work for the computer. Instead, it may be better to compile your MATLAB code into an executable that can be submitted as a job on Hoffman2.
Compiling
There is a handy tool mcc
which can take a MATLAB .m file and compile it into an executable that can be run outside of MATLAB. It is expensive to buy, but luckily Hoffman2 has already done the purchasing for you.
We have two example MATLAB scripts:
/u/home/FMRI/apps/examples/mcc/subfunction.m
This function can take any number of arguments and the text it prints out is based on the type of variables it receives.
function subfunction(varargin) fprintf('This is a MATLAB function that takes input arguments.\n'); for i=1:length(varargin) if( ~isempty(varargin{i}) ) switch class(varargin{i}) case 'double' fprintf('Argument #%d\t -- %s -- is a double\n', i, varargin{i}); case 'char' fprintf('Argument #%d\t -- %s -- is a char\n', i, varargin{i}); otherwise fprintf('Argument #%d\t -- is an unknown\n', i); end end end end
/u/home/FMRI/apps/examples/mcc/matlabScript.m
Makes use of the subfunction() function.
function matlabScript(varargin) fprintf('Passing numbers to the subfunction...\n'); subfunction(1, 2, 3); fprintf('Passing characters to the subfunction...\n'); subfunction('a', 'b', 'c'); fprintf('Passing whatever arguments you gave me on to the subfunction...\n'); for i=1:length(varargin) subfunction(varargin{i}); end end
Submitting
Known Issues
Compiling EEGLAB has thus far failed on Hoffman2. Compiling SPM5 or SPM8 may fail similarly. If you figure out how to do this, let us know.