Changing horizontal x axis from 0-1-0?

Hi. How to change the order of x axis in the plot function? Instead of 1 , 2 , 3... i would the axis to plot for 0.2, 0.4,...,0.9 , 1, 0.9,...,0.4, 0.2. ?
Thank a lot.

 Accepted Answer

%-----Example---------
t=0:0.1:20
y=sin(t);
plot(t,y)
%-------------------------
xl=get(gca,'xlim')
xti=[0.2:0.1:1 0.9:-0.1:0.2]
set(gca,'xtick',linspace(xl(1),xl(2),numel(xti)))
xti1=arrayfun(@num2str,xti,'un',0)
set(gca,'xticklabel',xti1)

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!