How to: Axis Xtick steps

조회 수: 30 (최근 30일)
Hello kity
Hello kity 2013년 1월 9일
답변: Ayomide Olabode 2019년 10월 12일
I plot something and Matlab auto chooses the axis step as 5, I want it 1.
how can i say that the step size should be 1.
I know you can use:
set(gca,'YTick',[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 etc]);
but this is just too long :)
  댓글 수: 1
Jan
Jan 2013년 1월 9일
A more compact form of the question:
How can I express "[1,2,3,4...]" shorter.
Defining vectors and arrays is one of the absolutely fundamental basics in Matlab. Therefore the language is called "Mat(rix)lab". Reading the "Getting Started" chapters of the documentation explains the basic usage of Matlab exhaustively. Therefore reading them is strongly recommended, while a forum is not the right place learning this.

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

채택된 답변

Jonathan Sullivan
Jonathan Sullivan 2013년 1월 9일
xbounds = xlim;
set(gca,'XTick',xbounds(1):xbounds(2));

추가 답변 (2개)

Ayomide Olabode
Ayomide Olabode 2019년 10월 12일
For a duirnal dataset for instance, do:
xlim([0 24]);
set(gca,'XTick',[0:2:24]) i.e. set(gca,'XTick',[minimum:stepsize:maximum])

kashif ali
kashif ali 2018년 7월 23일
use "xticks(0:1:100)"

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by