How do I create an X-Y plot using Simulink Real Time App Generator in MATLAB R2022b?

4 views (last 30 days)

I am trying to generate an app for my target system using the Simulink Real-Time App Generator in MATLAB R2022b. My model contains two signals, Speed and Torque, and I wish to plot them against each other in the generated app. Currently, when I designate the "Control Type" for these signals as "Axes", it creates two separate plots: one for Speed vs. Time and another for Torque vs. Time. However, my goal is to have a real-time Speed vs. Torque plot displayed in the app. The code view of the apps does not provide clear guidance, and I am uncertain about how the plots are generated. Is there a method to create such an X-Y plot within the app?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 16 Apr 2024 at 0:00
Up until the MATLAB R2024a release, there is no direct way to create an X-Y plot from the SLRT (Simulink Real-Time) App Generator tool. The developers are aware of the need for this functionality and are working towards resolving it in future releases.
If you want to plot two signals against each other, you can do so manually by modifying the code in the code view of the App Designer. In the case of Simulink Real-Time app generation, you can use the "getCallbackDataForSignal()" function to obtain the current data value from the model. More information about this function, along with some examples, can be found on the following documentation page:
The "connectCallback" function creates a callback that responds to new data available from the target computer. You can find more information about this function on the following documentation page:
Please refer to the attached example that shows how to create an X-Y plot using the above-mentioned functions. In the code view of the "RoseCurveApp.mlapp", you can find the "XYPlotCallback" function that uses the "getCallbackDataForSignal()" method to get the real-time data of the signals. In the "startupFcn," you can find the use of the "connectCallback" method that calls the "XYPlotCallback" to plot the X-Y graph.

More Answers (0)

Categories

Find more on Two y-axis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!