4

I would like to create a structure in Python which represents a Simulink model. I am aware of at least two ways of doing this - by parsing an ".mdl" file, or by using Matlab's api for communicating with the model.

Can you recommend good libraries or APIs for doing this?

In particular, I need to perform some processing on a Simulink model and I would like to do it in Python. Also I don't want to be constantly communicating with Matlab for doing this (so that I can release the floating license).

I have seen some parsers online, but they seem to be a little limited, usually not supporting components such as Bus Creators and Bus Selectors, Muxes, Demuxes, and reading UserData information.

Any help will be greatly appreciated.

Felipe Ferri
  • 3,179
  • 1
  • 26
  • 37

1 Answers1

1

Not my area, but noticed this Python parser which may be helpful.

Or you can purchase the Simulink Report Generator in order to save/manipulate the model as a XML file.

Or the *.mdl file is a readable ascii file. You could read it into a string with a fread statement, alter the string, then either save it to your format of choice or write it back out to a *.mdl file. My coworker thought of this, not me! But would require doing the editing/parsing with a routine you write yourself.

Ioannis Filippidis
  • 8,272
  • 8
  • 66
  • 96
KAE
  • 775
  • 1
  • 12
  • 30
  • Thanks for your response! Unfortunately, I need some more advanced features, for example obtaining routing information for Gotos and Froms and Bus Creators and Selectors. The parser you referred to seems to be a little limited in this area. – Felipe Ferri Feb 24 '12 at 19:56
  • Hi KE. I just saw today your edit. I would like to go for the alternative of reusing an existent library, but if the only alternative is to make my own parser then shall be it. I will investigate further the option of using the Simulink Report Generator, though. Thanks for the suggestion! – Felipe Ferri Mar 22 '12 at 17:01