Discussion:
[SciPy-user] Simulink API to Python?
Xiangyu Ding
2009-04-03 22:35:35 UTC
Permalink
I just started using python and plan to port a matlab simulation
software to python.

The main problem I had so far is that there doesn't seem to be a good
alternative to simulink in python. so my plan was to compile the
simulink model into C code and use some kind of API to transfer the
results into python. Currently I'm saving the result to hard drive and
load it in scipy, but this is very slow.

I was wondering, is there any existing module or something that will
allow the transfer to be done in memory?

Another problem is that I need to extract the state space matrix from
a simulink model, does anyone know a way to do this without using
matlab?

Thanks,

Xiangyu Ding
David Warde-Farley
2009-04-04 06:46:26 UTC
Permalink
Hi Xiangyu,
Post by Xiangyu Ding
I was wondering, is there any existing module or something that will
allow the transfer to be done in memory?
This sounds roughly like a job for Cython's numpy buffer support. It
would allow you call whatever C functions you need to and expose
contiguous blocks of memory (to which you have a pointer) to Python
code.

See the tutorial at: http://wiki.cython.org/tutorials/numpy

David
Stef Mientki
2009-04-04 16:41:10 UTC
Permalink
Post by Xiangyu Ding
I just started using python and plan to port a matlab simulation
software to python.
The main problem I had so far is that there doesn't seem to be a good
alternative to simulink in python.
I'm working on PyLab_Works, which should be able to be a replacement for
both Simulink and PowerSim.
although not yet released, you might get an impression here:
http://code.google.com/p/pylab-works/

cheers,
Stef
Neal Becker
2009-04-04 17:42:58 UTC
Permalink
Post by Xiangyu Ding
I just started using python and plan to port a matlab simulation
software to python.
The main problem I had so far is that there doesn't seem to be a good
alternative to simulink in python. so my plan was to compile the
simulink model into C code and use some kind of API to transfer the
results into python. Currently I'm saving the result to hard drive and
load it in scipy, but this is very slow.
What does simulink do that you miss? Is it the gui?

For what it's worth, electrical engineers used to design using schematics.
Now design is described in text. There's a reason for this. Schematics are
only useful for simple designs. Once they become more complex, it's much
more efficient to work with text. Not to mention the ability to manipulate
text, and the ability to transfer text-based designs between systems.
Xiangyu Ding
2009-04-04 18:16:16 UTC
Permalink
Thanks to everyone for the suggestions.
Post by Neal Becker
For what it's worth, electrical engineers used to design using schematics.
Now design is described in text.  There's a reason for this.  Schematics are
only useful for simple designs.  Once they become more complex, it's much
more efficient to work with text.  Not to mention the ability to manipulate
text, and the ability to transfer text-based designs between systems.
I guess I need to clarify that the software I'm writing is for
Reliability analysis purpose and lots of the system that it will be
used to test have schematics in Simulink, that's the main reason I
have to work with Simulink. I was considering porting everything to
python if there were parser that will convert Simulink model into some
equivalent model in python, the gui doesn't really matter. but I don't
know of any tools that will do this.

Loading...