Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Launch matlab and run a single command, returning an exit code of 1 if there's an error.
- #
- #For example, if you had a matlab command:
- #mungeData('infile.mat', 'outfile.mat')
- #
- #then with this script you can do
- #./runmatlab mungeData('infile.mat', 'outfile.mat')
- #
- #from the shell, or a makefile.
- #
- #Peter Meilstrup
- status=`mktemp -t matlab.status`
- #escape single quotes
- args=${@//\'/\'\'}
- $(which matlab) -nodesktop -nosplash -maci <<EOF
- try
- cd('$(pwd)');
- eval('${args}');
- catch e
- system('echo 1 > $status');
- fprintf(2,'%s',evalc('disp e'));
- exit();
- end
- system('echo 0 > $status');
- exit();
- EOF
- exit `cat $status`
Add Comment
Please, Sign In to add comment