4

I want to model a system in Simulink, and then access that simulation from a python program to feed it new conditions or inputs.

I know there is a module out there that allows you to access the Matlab engine from Python, but this is a little different.

I'd like to have a system modeled in Simulink, and monitor some hardware using Python. Then, every say quarter second or so, call Simulink, run the simulation using current conditions of the hardware, get some output and repeat the process. Basically I'm trying to play around with a real time simulator for hardware.

I am running Ubuntu 11.04

I know Python isnt ideally suited for this, but that's not the point. Any idea if this is possible? Or where I may start?

Michael
  • 281
  • 1
  • 5
  • 12
  • 1
    You may compile your Simulink program to executable using the Matlab compiler. The communication could be done using files. – kol Nov 20 '11 at 01:08

1 Answers1

4

There's an open-source HTTP and XML-RPC server for Matlab Simulink called SimServer:

http://simulinksimserv.sourceforge.net/

An example Python script has been provided(in the package) which shows how the XML-RPC interface can be used to Get and Set data in a running Simulink model.

Alex Brooks
  • 5,133
  • 4
  • 21
  • 27
  • Thanks for the link. Will check it out. – Michael Nov 22 '11 at 07:56
  • This seems to be Windows specific. I should have said I am running Ubuntu Linux. – Michael Nov 23 '11 at 02:17
  • I have looked at it github site: https://github.com/jonmills/simserver and the original developer said "SimServer builds and works fine on Windows XP. I haven't tried it, but it ought to be possible to get it working under Linux too, with a few changes to the mex_simserver.m file. All of the dependencies are cross-platform. " – Alex Brooks Dec 09 '11 at 02:56
  • Maybe if you ask it this way: "how do i change this mex file to make it run on linux", add the mex file and tag it matlab+mex you'll get better response here ? – Alex Brooks Dec 09 '11 at 03:23