一、安装FMIKIT
首先下载FMIKit-Simulink-master.zip文件,然后解压缩,在matlab中把添加该文件到路径
addpath("C:\FMIKit-Simulink-master")
二、加载FMIKIT
初始化FMIKIT在matlab命令行输入:
FMIKit.initialize()
三、安装Cmake
安装“cmake-3.21.0-windows-x86_64.msi”,用以编译用的
四、导出FMU模型文件
- 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。
在simulink测试导出的模型,
或者用FMIpy测试