Apologies for the rudimentary question, I'm very much a novice with Matlab. I am trying to set the x axis tick marks for a figure using XTick and it's not working. Can anyone tell me what I am missing here? The code is this:
figure
plot(damp1,'+r')
hold on
plot(damp2,'+r')
plot(lamp1,'ob')
plot(lamp2,'ob')
plot(mean,'xk' )
XTick = [0:1:6]
xlabel('Sample')
ylabel('Depth(m)')
legend('daily amplitude +','daily amplitude -','lunar amplitude +','lunar amplitude -','mean depth')
hold off

 채택된 답변

Wayne King
Wayne King 2011년 9월 27일

1 개 추천

Hi Jenny, use set(gca,'xtick')
plot(randn(17,1));
XTick = [0:16];
set(gca,'xtick',XTick)

댓글 수: 1

Jan
Jan 2011년 9월 27일
Prefer "0:16" instead of "[0:16]". Using square brackets around a vector, converts it to a vector. This wastes time.

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

추가 답변 (2개)

Jenny
Jenny 2011년 9월 27일

0 개 추천

Thank you!
UJJWAL
UJJWAL 2011년 9월 27일

0 개 추천

Hi Jenny,
In the program you have written you have not specified the variables. That is what you are storing in damp1, lamp1 etc is not specified. So that is a problem and may result in errors.
However even if you define all the variables, you should set Tick as follows :-
set(gca,'XTick',0:1:6); I am not describing the details as u r a new user. If you want to know more. just mail back to me
HAPPY TO HELP
UJJWAL

댓글 수: 1

Jenny
Jenny 2011년 9월 27일
Sorry, I didn't include the previous part of the file where the variables are defined. Thanks for the tip.

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

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

질문:

2011년 9월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by