How to use gca handles to change xtick properties
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am using MATLAB 2016, and I still can't figure out or find helpful documentation for how to change gca's xtick object. When I run my code I see the results in the command window, but when I plot it I see no change in my graph. Here is my code..
x = [0:0.001:(2*pi)]; y = (sin(x)).^2; figure(1) plot(x,y,'r') xlim([0 (2*pi)]); ax = gca; ax.XTick = [0 pi 2*pi]
Am I missing anything?
0 Kommentare
Antworten (1)
Pham Dang
am 11 Aug. 2016
Hi, you should use the set command to set your Xtick property.
set(gca,'Xtick',[0 pi 2*pi])
2 Kommentare
Pham Dang
am 12 Aug. 2016
Hi, the exact following code works for me :
x = [0:0.001:(2*pi)];
y = (sin(x)).^2;
plot(x,y,'r');
xlim([0 (2*pi)]);
set(gca,'Xtick',[0 pi 2*pi])
(The subsindex function is not used in those lines. Are you calling it for a specific purpose ?)
Siehe auch
Kategorien
Mehr zu 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!