File Exchange

image thumbnail


version (11.8 KB) by Felix Birkelbach
Parses a Modelica result file into a nested tree structure in Matlab


Updated 23 May 2018

View Version History

View License

This function parses a Modelica result file (*.mat) into a tree structue so that all variables can be accessed the same way as in Modelica.
The path to the result file has to be provided. The user can also pass a regular expression to the function to limit the return variables.
The output is a nested structure where all variables can be accessed via dot-notation. Arrays of objects in Modelica are parsed into arrays in Matlab.
res = modelicaImport(path, regex);
eg. res.object.subObject.variable
eg. res.object.subobject(1).variable
This function is pretty much a byproduct of a simulation project I did for university - I hope that is is useful. I have used this function with OpenModelica 1.9.1+dev (r22052) and Dymola 2015.

Cite As

Felix Birkelbach (2021). modelicaImport (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (14)

Stefan Walshe

Giancarlo Gentile

Thank you very much! Really useful function


David Roberts

Many thanks for this - it worked great in translating old Modelica data I had into a sensible format when I no longer had dymload.m available.

Julian Schneider


Stefano Fari

It worked like a charm. The resulting structure is the same you may find in your Modelica IDE.

Jonas Klingebiel

Jonas Klingebiel

Markus Schober

Thanks a lot, this solved the problem! I have found another small bug when reading out the combiTable1D data from OpenModelica. Your code only reads out the y-values of the table data twice, but not the input data. I have checked the raw data from OpenModelica and the values are there in data_1. Can you please fix this? Best regards, Markus

Felix Birkelbach

Hey Markus,

there was a problem, when modelica left out some fields in object arrays. I uploaded an updated version, that can handle this.

I hope, this solves your problem.


Markus Schober

Hello, i use this function to import some data from openmodelica to matlab, unfortunately it sometimes crashes and generates no output at all, depending on the input file and regex parameters. I am not really familiar with matlab so i cannot fix the problem on my own. Can someone please help me to fix the problems? Following two errors it can generate:
* Subscripted assignment between dissimilar structures.
* Error using cellfun
Non-scalar in Uniform output, at index 1, output 1.
Set 'UniformOutput' to false.


Many thanks in advance!

Felix Birkelbach

Hey Armando,

I never needed this myself, but I remember that there was another package here on the file exchange that provides this functionality.

You can find it here:


armando Salvati

hi, do you know some way how i can run Modelica from matlab?

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!