MATLAB: Increase gap between XTick and XTickLabel

MATLABxaxisxlabelxticklabel

Hi, I'm plotting a graph that has 262 measured points. I have a 262×1 text cell array called 'txt' which contains the data I want to label for the X labels. I have started out with this code to place the corresponding x labels with each measured point.
set(gca, 'XTick',1:262, 'XTickLabel',txt(:,1))
But if I use this code all the x labels are all muddled up and you cant read the text.
I have tried:
set(gca, 'XTick',1:30:262, 'XTickLabel',txt(:,1))
But each x label doesn't line up with the corresponding measured point. How can I label the x labels but have a gap around 30 measured points between each x label, but also ensuring the measured points line up with the corresponding x label? Thanks.

Best Answer

Tick labels are a 1:1 correspondence with the tick in sequence; the labels don't know about location; only ordinal number. Use
set(gca, 'XTick',1:20:262, 'XTickLabel',txt(1:20:262,1))
IOW, ensure use the labels that are in synch with the ticks.