Search this blog!

Friday, July 6, 2012

In MATLAB figure, how to change the X or Y axis ticks or labels?

A default case is the following where I plot 100 random numbers

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
var=rand(1,100);
figure; plot(1:100,var,'--rs');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

In X axis, the labels are placed 10 places apart.....0....10....20....30..... like that....If I want to have labels 2 places apart  1...3...5....7 till 100 how may I do it?


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

set(gca,'XTick',1:10:100) % Here gca refers to the handler of the current figure's axis

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



Now, try to do the same in Y-axis! Share your result :)









No comments:

Post a Comment