一、安装FMIKIT
将“FMIKit-Simulink-master.zip”文件解压缩后,拷贝到C盘根目录下面。
二、加载FMIKIT
1、添加FMIKIT路径:
在matlab命令行输入:addpath("C:\FMIKit-Simulink-master")
2、初始化FMIKIT:
在matlab命令行输入:FMIKit.initialize()
三、安装Cmake
安装“cmake-3.21.0-windows-x86_64.msi”
四、导出FMU
- Open the model to export
- Add external inputs and outputs (optional)
- Open **Simulation > Model Configuration Parameters** (CTRL+E)
- Under **Solver > Type** select **Fixed-step** for a Co-Simulation FMU or **Variable-step** for a Model Exchange FMU
- Under **Code Generation > System target file** click **Browse** and select **grtfmi.tlc** for a Generic Real-Time based FMU or **rtwsfcnfmi.tlc** for an S-function based FMU
- Under **Code Generation > CMake** select the **CMake generator** for your toolchain
- Apply the **Model Configuration Parameters** dialog
- Select **Code > C/C++ Code > Build Model** (CTRL+B) to export the FMU to the current working directory。