You may have a MATLAB function that does what you want inside add_em.m
function add_em(x, y) x_plus_y = x + y; disp(x_plus_y); exit;
and then invoke it from the Unix command line using the -r switch. Example:
matlab -nodesktop -nojvm -nosplash -r "add_em(3, 8)"
Options - suppress the desktop, java and splash, so the script / function will execute without additional overhead.
You can optionally suppress the welcome / copyright message MATLAB by redirecting the output to a log file (for any calculations) or ending, for example, the output to get something printed on the terminal
matlab -nosplash -nodesktop -nojvm -r "add_em(3, 8)" | tail -n 3
Update . Just found out about this post / replies with related information: suppress the initial Matlab message
gevang
source share