MATLAB: How to set the axes ticks to evenly spaced non-monotonically increasing axes vectors

MATLABmonotonicallytickticklabel

I want to set the axes XTicks to evenly-spaced, non-monotonically increasing axes vectors. When I execute
x = linspace(-pi,pi-2*pi/100,100);
y = sin(3*x)./(3*x);
plot(x*180/pi,y);
axis tight
myTicks = get(gca, 'xtick');
myTicks(myTicks<0) = myTicks(myTicks<0) + 360;
set(gca, 'xtick', myTicks)
I obtain the result
??? Error using ==> set
Values must be monotonically increasing.
I want to be able to set the XTicks vector to a non-monotonic axis vector so that when I use GINPUT to read the pointer coordinates I do not need to keep track of the differences between the actual XTicks and the value that I want them to represent.

Best Answer

The ability to specify non-monotonically increasing vectors as XTicks is not available in MATLAB 7.2 (R2006a).
As a workaround, change the XTickLabels to the value that the XTicks are supposed to represent on the image. Since this will not modify the XTicks, it is necessary to modify the value returned by GINPUT to reflect the difference between the XTicks and the XTickLabels. The following is an example of this:
x = linspace(-pi,pi-2*pi/100,100);
y = sin(3*x)./(3*x);
plot(x*180/pi,y);
axis tight
myTicks = get(gca, 'xtick');
myTicks(myTicks<0) = myTicks(myTicks<0) + 360;
set(gca, 'xticklabel', myTicks)
[x_val,y_val] = ginput;
x_val(x_val<0) = x_val(x_val<0) + 360;