I am trying to load a FMU (FMI2), generated from Dymola, in a Matlab script. I have tried using the loadlibrary
function to load the dll, but I am not sure I have supplied the appropriate headers. I tried with fmi2Functions
, fmi2FunctionTypes
and fmi2TypesPlatform
.
What would be the basic steps to load such a dll, initialize the simulation and then run a step?
Here's my current code:
libname = 'toto';
ext = '.dll';
libfile = [libname ext];
if ~libisloaded(libname)
loadlibrary(libfile,'dymosim.h','addheader','fmi2Functions','addheader','fmi2TypesPlatform','addheader','fmi2FunctionTypes')
end
There is no direct FMI support in MATLAB.
You have the following possibilities:
Import your FMU in MATLAB/Simulink (if you have it) either with the native FMU import by Mathworks or e.g. the free FMI-Kit by Dassault systems. From MATLAB you can then interact with the Simulink Model with the imported FMU (e.g. simulate it, get results ...)
Get the (commercial) FMI toolbox from Modelon https://modelon.com/fmi-toolbox/, which brings MATLAB support
With the MATLAB-Python inteface (https://de.mathworks.com/products/matlab/matlab-and-python.html) you should be able to use one of the Python libraries that support FMU simulation such as fmpy (https://github.com/CATIA-Systems/FMPy) to load and simulate your FMU from Python. (I have not tested this.)