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