Customizing xticks yields error: " Undefined function 'xticks' for input arguments of type 'double'."

조회 수: 32 (최근 30일)
I am trying to customize the x- and yticks on my plot axes. But even running the basic example provided by Matlab
x = linspace(-10,10,200);
y = cos(x);
plot(x,y)
xticks([-3*pi -2*pi -pi 0 pi 2*pi 3*pi])
xticklabels({'-3\pi','-2\pi','-\pi','0','\pi','2\pi','3\pi'})
yticks([-1 -0.8 -0.2 0 0.2 0.8 1])
(see link https://de.mathworks.com/help/matlab/creating_plots/change-tick-marks-and-tick-labels-of-graph-1.html) will yield the error message cited in the title. Restart did not help. Running R2014b, 64-bit, on an OS X Yosemite Mac.
What is that error due to and how can I solve it?
Thanks a lot for the help!

채택된 답변

Rik
Rik 2017년 12월 8일
The xticks function was introduced in R2016b. In earlier releases you must use the code below (this code also works on newer releases).
x = linspace(-10,10,200);
y = cos(x);
plot(x,y)
set(gca,'XTick',[-3*pi -2*pi -pi 0 pi 2*pi 3*pi])
set(gca,'xticklabel',({'-3\pi','-2\pi','-\pi','0','\pi','2\pi','3\pi'}))
set(gca,'YTick',[-1 -0.8 -0.2 0 0.2 0.8 1])
  댓글 수: 2
Rik
Rik 2017년 12월 14일
If you found this answer useful, please mark it as accepted answer. It will make it easier for other people with the same question to find an answer, as well as give me reputation points. If this didn't solve your question, please comment with what problems you are still having.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by