Search code examples
pythonmatlabsimulinkmlabwrap

Error on set_param SimulationCommand start - "memory allocation failed or you have no X connection"


I'm trying to launch a simulink simulation using python script ( mlabwrap as python wrapper for matlab ). I open the simulink *.mdl file using:

open_system("thermo","loadonly");

I use set_param to initialize the simulation:

set_param("thermo", 'SimulationCommand', 'start');

This throws the following error:

An error occurred when changing the simulation execution status. This may occurif a memory allocation failed or if you have no X connection

If I just execute sim("thermo") everything works.

Unfortunatelly I would like to use set_param instead of sim.

How can I use set_param("thermo", 'SimulationCommand', 'start'); and run it from terminal, without X server?

I'm using Matlab2009b on Ubuntu.

EDIT:

As it turned out, if I ran the simulation logged in as a user with X server, the everything works even with set_param ...

But I still wonder, if it is possible to run the simulation, without the X server running...


Solution

  • As it turned out, you cannot start simulation using set_param without the X server:

    "If you use matlab -nodisplay to start a session, you cannot use set_param to run your simulation."

    EDIT: official docs link ( as @Daniel pointed out )