Hi Igor Slivinschi,
I understand that you have developed a project involving a GUI created in MATLAB's App Designer, which interacts with a Simulink model through a Data Dictionary (DD). Your project requires starting and stopping the Simulink simulation from the GUI and exchanging data between the Simulink model and the GUI. You are now looking to compile this project into a standalone application (.exe) using MATLAB Compiler and Simulink Coder. You can follow the below steps to acheive the same.
- Use MATLAB Compiler to compile the GUI created in App Designer into an executable (.exe). This process converts your MATLAB code into a standalone application that can be run without a MATLAB license. To compile the GUI, use "mcc -m YourApp.m", where YourApp.m is the main function or script that launches your App Designer app.
- For the Simulink model, use Simulink Coder to generate C code. This code needs to be compiled into a library or executable that can be called from your GUI application.
- Data Exchange between GUI and Simulink Model: For sending parameters from the GUI to the Simulink model (now in C code), consider saving the parameters to a .mat file or a text file from the GUI. The C code can then read these parameters at the start of its execution.
- To replace the functionality of "add_exec_event_listener" for state feedback from the Simulink model to the GUI, you can implement a polling mechanism in your GUI that regularly checks for updates in a specified file or through a specific IPC (Inter-Process Communication) mechanism that your compiled Simulink model writes to.
Here are the steps to implement a polling mechanism for GUI updates based on a Simulink model's state:
- Simulink Model Side: Continuously write the model's state to a file or send it via an IPC mechanism at regular intervals.
- GUI Application Side: Set up a timer that triggers a function to check for updates from the Simulink model periodically.
- Reading Model State: In the triggered function, read the model's state from the specified file or IPC channel.
- Update GUI: Use the read state information to update the GUI accordingly, reflecting the current state of the Simulink model.
- Repeat: Continue this process as long as the GUI is running, ensuring the GUI remains updated with the latest state information from the model.
For compiling MATLAB applications, refer to the MATLAB Compiler documentation at https://www.mathworks.com/help/compiler/index.html.
For generating C code from Simulink models, see the Simulink Coder documentation at https://www.mathworks.com/help/rtw/index.html.
For App Designer, the documentation can be found at
Hope this helps!