Take the 2-minute tour ×

I thought a Makefile was just executing the stated shell commands, but things seem not that simple : sample.m is a minimal matlab program that displays a word on screen. When launched from a Makefile, it does not behave the same as when launched from the shell...

From the shell

alex:~$ matlab -nosplash -nodisplay -r "sample"

-> Displays the word correctly

From a Makefile

all :  
matlab -nosplash -nodisplay -r "sample"  

alex:~$ make

-> Displays the word with a blue bounding box

How can it be different ? I'm using Matlab 2010a on a Ubuntu 10.04 machine. No arguments are passed to the sample.m script.

share|improve this question
I don't have Matlab to play with, but I can suggest a long shot: could it be that there is more than one version of Matlab on your machine? Instead of matlab ..., try which matlab and see if they agree. Also, please post sample (the simplest version that gives the behavior). –  Beta Feb 7 '11 at 21:24
I am not able to reproduce this. I am on Fedora 12, Matlab Version (R2009b) 32-bit –  Ghaul Feb 7 '11 at 21:30
@Beta : Only one version of matlab. which matlab => usr/bin/matlab. sample.m is as follows : ScreenNumber=0; [win, winRect]=Screen('OpenWindow', ScreenNumber); DrawFormattedText(win, 'Hello world', 'center', 'center', [127 127 127]); Screen('Flip', win); KbWait([],3); Screen('CloseAll'); –  alxpublic Feb 8 '11 at 14:10

1 Answer 1

up vote 0 down vote accepted

Did you make sure you quit Matlab after running the script?

The Matlab console will linger in memory, invisible when run from make, and some resources will remain locked.

try this in your Makefile:

matlab -nosplash -nodisplay -r "sample; exit"

I tested sample.m and it works here.

share|improve this answer
Bingo, this seems to work ! Thanks... –  alxpublic Feb 13 '11 at 11:19

Your Answer


