Skip to content

Instantly share code, notes, and snippets.

@vaivads
Created August 13, 2013 15:06
Show Gist options
  • Save vaivads/6222150 to your computer and use it in GitHub Desktop.
Save vaivads/6222150 to your computer and use it in GitHub Desktop.
MATLAB: running in batch with and without figures
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% To run batch file with matlab commands.
% Execute from terminal:
cat batch_file.m | matlab -nodisplay -logfile log.txt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% To run batch file that includes plotting.
% 1) create framebuffer X server executing from terminal:
Xvfb :1 &
% 2) run batch file (the number :1 should be the same as for framebuffer)
cat batch_file.m | matlab -display :1 -logfile log.txt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% To send email when finnishing (Matlab 2013+)
% Include following lines at the end of your batch file
setpref('Internet','E_mail','send_from@email.adress')
setpref('Internet','SMTP_Server','smtp.server.address') % for IRFU use sol.irfu.se
sendmail('send_to@email.adress','Message text')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment