start matlab script from linux command line

If you want to start a matlab script from terminal (in linux or mac), you can use following command

matlab -nojvm -nodisplay -nosplash -r "addpath ('/path/to/script'), test_script(imgSize,'savepath'), exit"

Then matlab starts, executes the script and exits again.

test_script looks something like

function test_script(j,savepath)
img = rand(imgSize,imgSize);
imwrite(img, sprintf('%s/myTestImg.png',savepath),'png');
return

blog_tags: 

Add new comment

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <img> <br> <p> <span>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Use [collapse] and [/collapse] to create collapsible text blocks. [collapse collapsed] or [collapsed] will start with the block closed.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Code snippets in <code>...</code> or <source>...</source> automatically will be pretty printed.
  • Use [collapse] and [/collapse] to create collapsible text blocks. [collapse collapsed] or [collapsed] will start with the block closed.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Target Image