SCOPE TO GUI AXES NOT FITTING

3 Ansichten (letzte 30 Tage)
Claire Saez
Claire Saez am 9 Okt. 2024
Beantwortet: Aravind am 11 Okt. 2024
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)

Antworten (1)

Aravind
Aravind am 11 Okt. 2024
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!

Kategorien

Mehr zu Labels and Annotations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by