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

4 次查看(过去 30 天)
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.

回答(1 个)

Tejas
Tejas 2024-9-17
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.

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by