How to link a Simulink's Scope to a App Designer's Axes

10 ビュー (過去 30 日間)
Jesus Garcia
Jesus Garcia 2019 年 4 月 12 日
回答済み: Jasmine Poppick 2024 年 4 月 26 日
I am developing an application on App Designer to control a Simulink Model. The one of the goal is to show the Simulink’s Scopes (graph output while the simulation is running) inside of the App Designer Application Axes.
Is there any way to link the App Designer’s Axes to the Simulink Scope to mirror the graph with the Simulation is running?
  • What is the best way to do it? Currently I am accessing the Simulation Data directly and Plot it into the App Designer’s Axes, but the Performance/Simulation time get very bad.
Thank you.

回答 (2 件)

Samya
Samya 2023 年 6 月 29 日
To link the App Designer's Axes to the Simulink Scope and mirror the graph while the simulation is running, you can use the Simulink Real-Time interface. This interface allows you to connect your Simulink model to external applications, such as App Designer.
Here's an approach you can follow:
  1. In your Simulink model, add a Simulink Real-Time (Simulink Desktop Real-Time) block from the Simulink Real-Time Library. This block allows you to send data from the Simulink model to external applications.
  2. Configure the Simulink Real-Time block to output the data you want to display in the App Designer's Axes. You can use a scope or other blocks to capture the desired signals.
  3. In your App Designer application, establish a connection to the Simulink model using the Simulink Desktop Real-Time API. This API provides functions to interact with the Simulink Real-Time block.
  4. Create a listener or a callback function in your App Designer application that receives the data from the Simulink model.
  5. Update the App Designer's Axes with the received data. You can use the `plot` or `line` functions to update the graph in real-time.
By using the Simulink Real-Time interface, you can avoid accessing the simulation data directly, which can cause performance issues. Instead, you receive the data directly from the Simulink model while it is running, ensuring better performance.
For more information on using the Simulink Real-Time interface, you can refer to the documentation: [Simulink Real-Time]

Jasmine Poppick
Jasmine Poppick 2024 年 4 月 26 日
Starting in R2024a, you can use App Designer to interactively create an app for a Simulink model, which includes the capability to easily and performantly visualize signal data in the app using the new time scope UI component.
In addition, you can:
  • Add UI components configured specifically to interact with your model, such as a simulation start/stop control and a simulation progress bar.
  • Tune model variables from the app while the simulation runs by connecting UI components to variables.
For more information, see Create App for Simulink Model.

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by