How to show a figure in the MATLAB App designer with both X and Y axis from signal in simulink real-time model?

How can we customize the x-axis of the instrumented axes in MATLAB App (with model running on Speedgoat)? I wanted to plot Speed vs Torque (signals from Simulink model) (in the axes) instead of separately plotting them with respect to time.

Answers (1)

Hello Devesh,
Start by adding an 'Axes Component' in App Designer. Below this component, place a button and assign a 'ButtonPushed' callback to it. Within this callback, follow these steps:
target_object = slrealtime('TargetPC1');
speedData = getsignal(target_object, 'blockPath', portIndex);
torqueData = getsignal(target_object, 'blockPath', portIndex);
  • Use the 'plot’ function to display the speed and torque data.
plot(app.UIAxes, speedData, torqueData);
With this setup, each time the button is clicked, real-time speed and torque data will be fetched and plotted in App Designer.

Categories

Find more on Simulink in Help Center and File Exchange

Products

Release

R2022b

Asked:

on 21 Feb 2024

Answered:

on 17 Sep 2024

Community Treasure Hunt

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

Start Hunting!