Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Accessing OPC-based Matlab Files (.slx)



  • I need to produce a Matlab (SimEvents) compatible file (extension is .slx), which uses the OPC standard. I found this library on github: https://github.com/dbzhang800/QtOfficeOpenXml which I could perhaps build on to create access to .slx files. Using Qt5.7, I found a small issue but could bypass the compile error. Anyway, I would still need to create the whole .slx structure etc but perhaps there is somebody out there who has already done this. If so, I would like to hear from you.


  • Moderators

    @ModelTech QtOfficeOpenXml is for office documents (e.g. reports, spreadsheets, etc.); these are quite different to MATLAB Simulink files.

    I suggest you ask around the MathWorks forums for a C/C++ library or API that can read/write .slx files.

    Alternatively, you could start by studying the contents of existing .slx files. They are actually .zip files, so you can extract their contents using any Zip decompressor (e.g. 7-Zip).



  • I am aware of these aspects and already did a first study of the content of example .slx files and .mlx files I have. I am basically considering to extend the QtOfficeOpenXml library to deal with these Matlab file types, which are in essence following a similar OPC-based structure so I would expect this is a viable route. Or do you know of a better alternative?



  • It turns out that my approach is feasible. After half a day of coding, I am able to create empty model files in .slx format using the OPC part of the referred library. I just need to parameterize a few things in this library to make sure that the [Content_Types].xml file is correct as it currently uses one hard-coded Office default that Matlab does differently. This concerns the core properties and there is a Part that Matlab creates in the Package that is not listen in the [Content_Types].xml file (which seems not 100% conform the standard).

    Edit: After a bit of hacking, I was able to fix all things MathWorks seems to do differently than the standard. Solution is not very nice but works for now. Next step is to generate non-empty model files.


  • Moderators

    @ModelTech Thanks for sharing your update! It sounds like you're making good progress with building on top of QtOfficeOpenXml.

    I can't think of any better alternative, except to ask around and see if someone else has already made a library that reads/writes .slx files. (I did a quick Google but didn't find any, so your path might be the best)

    All the best.



  • After about one day of programming, I now generate some first partial models from my tool. This is how a model looks in my tool:

    MPEG4 SP Decoder Model in DataFlow Modeller

    And this is how it looks like in DiffPlug, a free Matlab Simulink model viewer:

    MPEG4 SP Decoder Model in DiffPlug

    Today, I also gained access to Matlab Simulink and the same model also opens in Matlab although with a few warnings (generated Matlab Simulink model is still far from complete). Resolving one of these warnings will require an extra small hack in the QtOfficeOpenXML library, but the approach works. So, problem solved (still have a linking issue for QtOfficeOpenXML on windows but hope to solve that later)



  • For those who are interested, this is how the same example currently looks in Simulink

    MPEG4_SP in Simulink



  • Well, nice work. In my opinion as far as the model goes, I think your tool looks best!


Log in to reply