SCOPE TO GUI AXES NOT FITTING

조회 수: 2 (최근 30일)
Claire Saez
Claire Saez 2024년 10월 9일
답변: Aravind 2024년 10월 11일
How do I fix my axes to match the scope output? This is my code:
function EnableButtonPushed(app, event)
desiredSpeedValue = app.DesiredSpeedEditField.Value;
assignin('base', 'desired_speed', desiredSpeedValue);
assignin('base', 'KpOut', app.KpEditField.Value);
assignin('base', 'KiOut', app.KiEditField.Value);
assignin('base', 'KdOut', app.KdEditField.Value);
sim('finalfuzzy', 'StopTime', '10');
dataout = evalin('base', 'dataout');
plot(app.SpeedPlot,dataout.time,dataout.signals.values)

답변 (1개)

Aravind
Aravind 2024년 10월 11일
The issue you are experiencing occurs when the tick values on the x and y axes do not match their labels. To fix this, you can manually set the ticks and their labels for both axes of the graph. You can do this by adding the following lines of code before calling the plot function:
app.SpeedPlot.XTick = 0:10; % x ticks will be integers from 0 to 10
app.SpeedPlot.XTickLabel = string(0:10); % set the x tick labels as strings of integers from 0 to 10
app.SpeedPlot.YTick = 0:10; % y ticks will be integers from 0 to 10
app.SpeedPlot.YTickLabel = string(0:10); % set the y tick labels as strings of integers from 0 to 10
These lines set the ticks on the x and y axes to integers from 0 to 10. You can adjust these values according to your requirements.
For more information about specifying axis tick values and labels, you can refer to the official MathWorks documentation at the following link: https://www.mathworks.com/help/matlab/creating_plots/change-tick-marks-and-tick-labels-of-graph-1.html.
I hope this helps!

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by