# psychtoolbox + matlab compiler ?

**URL:** <https://psychtoolbox.discourse.group/t/psychtoolbox-matlab-compiler/1976>\
**Category:** Uncategorized\
**Created:** [May 30, 2005, 3:07pm UTC](https://psychtoolbox.discourse.group/t/psychtoolbox-matlab-compiler/1976 "2005-05-30T15:07:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [May 30, 2005, 3:07pm UTC](https://psychtoolbox.discourse.group/t/psychtoolbox-matlab-compiler/1976/1 "2005-05-30T15:07:06Z")

</div>

Dear psychtoolbox users,  
  
We are currently in the process of deciding which matlab toolboxes we   
are going to order together with the latest matlab version. We are   
interested in the matlab compiler, to generate stand-alone versions of   
programs that will often use the psychtoolbox functions. But before   
deciding whether or not to order this expensive compiler toolbox, we   
would like to verify some things:  
  
(1) A fast lecture of the 'recent' messages on the subject suggests that   
there have been some problems with screen functions in combination with   
the compiler, but that these problems are overcome in the more recent   
versions (7) of Matlab. Are people still using the compiler in   
combination with psychtoolbox, and are there issues, or can people   
second a satisfactory experience with this combination in the more   
recent versions of matlab and psychtoolbox?  
  
(2) Except for the possibility of generating standalone programs, we   
would like to know whether there is any advantage to running a compiled   
compared to running in the usual matlab environment. We would expect a   
compiled program to run faster than a program that is read as a script,   
but on the other hand, we also expect that routines are well optimized   
for common usage in matlab nowadays, as well as the crucial components   
of the psychtoolbox set of functions. Can we expect an increase in speed   
for parts of psychophysical experiments (such as generating/loading   
images from files) or data fitting when using a compiled rather than an   
interpreted matlab program? Any experiences here?  
  
We are interested in all suggestions, remarks and 'user stories', both   
positive and negative.  
  
Thanks in advance,  
Peter.

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [May 31, 2005, 12:07am UTC](https://psychtoolbox.discourse.group/t/psychtoolbox-matlab-compiler/1976/2 "2005-05-31T00:07:05Z")

</div>

Hi Peter,  
  
I'm currently using Matlab 7, Psychtoolbox 2.54 and the latest   
version of the Matlab Compiler on Windows XP.   
  
Unfortunately, I am unable to successfully compile SCREEN into a   
standalone executable. I'm still playing around with it, looking   
for a solution. The error I get is apparently a common one (see   
forum msq 2919):  
  
"Screen('openwindow'), when run from a compiled exectutable, exits   
with an error 'cannot access MATLAB command window' "  
  
If anyone has found a way around this problem, I would appreciate   
hearing the solution. At the moment, I can't provide a positive   
experience with the Matlab compiler.  
  
Regards,  
  
Daniel Little  
  
  
  
--- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), Peter Claessens   
\<peter.claessens@p...\> wrote:  

> \> Dear psychtoolbox users,  
> \>   
> \> We are currently in the process of deciding which matlab toolboxes

we   

> \> are going to order together with the latest matlab version. We are   
> \> interested in the matlab compiler, to generate stand-alone

versions of   

> \> programs that will often use the psychtoolbox functions. But

before   

> \> deciding whether or not to order this expensive compiler toolbox,

we   

> \> would like to verify some things:  
> \>   
> \> (1) A fast lecture of the 'recent' messages on the subject

suggests that   

> \> there have been some problems with screen functions in combination

with   

> \> the compiler, but that these problems are overcome in the more

recent   

> \> versions (7) of Matlab. Are people still using the compiler in   
> \> combination with psychtoolbox, and are there issues, or can people   
> \> second a satisfactory experience with this combination in the more   
> \> recent versions of matlab and psychtoolbox?  
> \>   
> \> (2) Except for the possibility of generating standalone programs,

we   

> \> would like to know whether there is any advantage to running a

compiled   

> \> compared to running in the usual matlab environment. We would

expect a   

> \> compiled program to run faster than a program that is read as a

script,   

> \> but on the other hand, we also expect that routines are well

optimized   

> \> for common usage in matlab nowadays, as well as the crucial

components   

> \> of the psychtoolbox set of functions. Can we expect an increase in

speed   

> \> for parts of psychophysical experiments (such as

generating/loading   

> \> images from files) or data fitting when using a compiled rather

than an   

> \> interpreted matlab program? Any experiences here?  
> \>   
> \> We are interested in all suggestions, remarks and 'user stories',

both   

> \> positive and negative.  
> \>   
> \> Thanks in advance,  
> \> Peter.

---

<div class="post-metadata">

**Author:** ![franswcornelissen](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@franswcornelissen](https://psychtoolbox.discourse.group/u/franswcornelissen)\
**Post date:** [May 30, 2005, 9:25pm UTC](https://psychtoolbox.discourse.group/t/psychtoolbox-matlab-compiler/1976/3 "2005-05-30T21:25:22Z")

</div>

Dear Peter,  
  
No experience with the compiler.  
I seem to remember that if you run your programs as a function, rather then as a script,   
matlab will compile everything before running. Same goes for code within loops. So I   
guess there's generally little if any speed benefit from compiling.  
  
I'd spend my money on a faster computer or more video memory.  
  
gr.  
frans  
  
  
  
  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), Peter Claessens \<peter.claessens@p...\> wrote:  
> \> Dear psychtoolbox users,  
> \>   
> \> We are currently in the process of deciding which matlab toolboxes we   
> \> are going to order together with the latest matlab version. We are   
> \> interested in the matlab compiler, to generate stand-alone versions of   
> \> programs that will often use the psychtoolbox functions. But before   
> \> deciding whether or not to order this expensive compiler toolbox, we   
> \> would like to verify some things:  
> \>   
> \> (1) A fast lecture of the 'recent' messages on the subject suggests that   
> \> there have been some problems with screen functions in combination with   
> \> the compiler, but that these problems are overcome in the more recent   
> \> versions (7) of Matlab. Are people still using the compiler in   
> \> combination with psychtoolbox, and are there issues, or can people   
> \> second a satisfactory experience with this combination in the more   
> \> recent versions of matlab and psychtoolbox?  
> \>   
> \> (2) Except for the possibility of generating standalone programs, we   
> \> would like to know whether there is any advantage to running a compiled   
> \> compared to running in the usual matlab environment. We would expect a   
> \> compiled program to run faster than a program that is read as a script,   
> \> but on the other hand, we also expect that routines are well optimized   
> \> for common usage in matlab nowadays, as well as the crucial components   
> \> of the psychtoolbox set of functions. Can we expect an increase in speed   
> \> for parts of psychophysical experiments (such as generating/loading   
> \> images from files) or data fitting when using a compiled rather than an   
> \> interpreted matlab program? Any experiences here?  
> \>   
> \> We are interested in all suggestions, remarks and 'user stories', both   
> \> positive and negative.  
> \>   
> \> Thanks in advance,  
> \> Peter.

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [June 2, 2005, 1:12am UTC](https://psychtoolbox.discourse.group/t/psychtoolbox-matlab-compiler/1976/4 "2005-06-02T01:12:35Z")

</div>

Hi Brian,  
  
I was imprecise in my last post. I am using screen(0,'openwindow')  
The actual error message I get is "GetMATLABcommandWindow() failed to   
find the Matlab command window". GetMATLABcommandWindow() is called   
by screen(0,'openwindow'). Have you had this problem? I'd be   
interested in knowing what if any modifications you've had to make to   
get screen to compile properly. I'm fairly certain that I've followed   
all of the procedures listed in the Compiler manual (setting the   
path, installing MRC, compiling a function instead of a script, etc.)   
but I'm not able to get it to work.   
  
Regards,  
  
Daniel Little  
  
--- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "BrSchnitz" \<brschnitz@y...\>   
wrote:  

> \> Don't know if this has been answered already, but in my experience,   
> \> using the syntax screen(0,'openwindow') is what is   
> \> appropriate...screen('openwindow') does not work. This is the case   
> \> when using matlab 7 with psychtoolbox 2.54, anyway. Also, I've

found   

> \> no problems when using the matlab compiler to generate standalone   
> \> functions that use SCREEN with the exception of Rush...I think the   
> \> issue here is that the matlab compiler isn't really good at dealing   
> \> with eval-type functions, and so strings that are passed to an eval-  
> \> type function (such as Rush) are skipped over by the compiler.  
> \>   
> \> We'll have to see if I can get that aspect of my code working...I   
> \> hope this helps others with theirs.  
> \>   
> \> Brian  
> \>   
> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "greymatter\_24"

\<littld02@t...\>   

> \> wrote:  
> \> \> Hi Peter,  
> \> \>   
> \> \> I'm currently using Matlab 7, Psychtoolbox 2.54 and the latest   
> \> \> version of the Matlab Compiler on Windows XP.   
> \> \>   
> \> \> Unfortunately, I am unable to successfully compile SCREEN into a   
> \> \> standalone executable. I'm still playing around with it, looking   
> \> \> for a solution. The error I get is apparently a common one (see   
> \> \> forum msq 2919):  
> \> \>   
> \> \> "Screen('openwindow'), when run from a compiled exectutable,

exits   

> \> \> with an error 'cannot access MATLAB command window' "  
> \> \>   
> \> \> If anyone has found a way around this problem, I would appreciate   
> \> \> hearing the solution. At the moment, I can't provide a positive   
> \> \> experience with the Matlab compiler.  
> \> \>   
> \> \> Regards,  
> \> \>   
> \> \> Daniel Little  
> \> \>   
> \> \>   
> \> \>   
> \> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), Peter Claessens   
> \> \> \<peter.claessens@p...\> wrote:  
> \> \> \> Dear psychtoolbox users,  
> \> \> \>   
> \> \> \> We are currently in the process of deciding which matlab   
> \> toolboxes   
> \> \> we   
> \> \> \> are going to order together with the latest matlab version. We   
> \> are   
> \> \> \> interested in the matlab compiler, to generate stand-alone   
> \> \> versions of   
> \> \> \> programs that will often use the psychtoolbox functions. But   
> \> \> before   
> \> \> \> deciding whether or not to order this expensive compiler

toolbox,   

> \> \> we   
> \> \> \> would like to verify some things:  
> \> \> \>   
> \> \> \> (1) A fast lecture of the 'recent' messages on the subject   
> \> \> suggests that   
> \> \> \> there have been some problems with screen functions in   
> \> combination   
> \> \> with   
> \> \> \> the compiler, but that these problems are overcome in the more   
> \> \> recent   
> \> \> \> versions (7) of Matlab. Are people still using the compiler in   
> \> \> \> combination with psychtoolbox, and are there issues, or can   
> \> people   
> \> \> \> second a satisfactory experience with this combination in the   
> \> more   
> \> \> \> recent versions of matlab and psychtoolbox?  
> \> \> \>   
> \> \> \> (2) Except for the possibility of generating standalone

programs,   

> \> \> we   
> \> \> \> would like to know whether there is any advantage to running a   
> \> \> compiled   
> \> \> \> compared to running in the usual matlab environment. We would   
> \> \> expect a   
> \> \> \> compiled program to run faster than a program that is read as a   
> \> \> script,   
> \> \> \> but on the other hand, we also expect that routines are well   
> \> \> optimized   
> \> \> \> for common usage in matlab nowadays, as well as the crucial   
> \> \> components   
> \> \> \> of the psychtoolbox set of functions. Can we expect an increase   
> \> in   
> \> \> speed   
> \> \> \> for parts of psychophysical experiments (such as   
> \> \> generating/loading   
> \> \> \> images from files) or data fitting when using a compiled rather   
> \> \> than an   
> \> \> \> interpreted matlab program? Any experiences here?  
> \> \> \>   
> \> \> \> We are interested in all suggestions, remarks and 'user

stories',   

> \> \> both   
> \> \> \> positive and negative.  
> \> \> \>   
> \> \> \> Thanks in advance,  
> \> \> \> Peter.

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [June 2, 2005, 3:23pm UTC](https://psychtoolbox.discourse.group/t/psychtoolbox-matlab-compiler/1976/5 "2005-06-02T15:23:54Z")

</div>

Daniel,  
  
I do indeed have the same problem...it turns out that, at least as   
far as I know, in order to use screen commands you MUST have MATLAB   
running so that it can access the command window. This is a severe   
limitation to using SCREEN functions in compiled code...I'll be   
spending my day today looking for some sort of resolution and/or   
workaround to this issue.  
  
Brian  
  
--- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "greymatter\_24" \<littld02@t...\>   
wrote:  

> \> Hi Brian,  
> \>   
> \> I was imprecise in my last post. I am using screen(0,'openwindow')  
> \> The actual error message I get is "GetMATLABcommandWindow() failed

to   

> \> find the Matlab command window". GetMATLABcommandWindow() is

called   

> \> by screen(0,'openwindow'). Have you had this problem? I'd be   
> \> interested in knowing what if any modifications you've had to make

to   

> \> get screen to compile properly. I'm fairly certain that I've

followed   

> \> all of the procedures listed in the Compiler manual (setting the   
> \> path, installing MRC, compiling a function instead of a script,

etc.)   

> \> but I'm not able to get it to work.   
> \>   
> \> Regards,  
> \>   
> \> Daniel Little  
> \>
