In Matlab: How to keep all xTicks but xTicklabels just on every 6 xTicks?

Viewed 6949

I have created a graph with data from an Excel file. I need to keep all the xticks but the xticklabels to appear just on every 6 ticks. I have tried doing this:

tickStep=6;
Sheet=2;
filename='MyData.xlsx';
[~,xAxis]=xlsread(filename,Sheet,'A2:A60'); 
yAxis=xlsread(filename,Sheet,'B2:B60'); 
plot(1:numel(xAxis),yAxis) 
set(gca,'xtick',1:numel(xAxis)) 
set(gca,'xticklabel',xAxis(1:tickStep:numel(xAxis)))

Unfortunately it does not work as all the xticks are plotted, but the xticklabels appear upon each xtick instead of every 6th like I was trying to achieve. I have spent quite a long time thinking about the solution:-(. I need help. Thanks.

edit: I've included an image to help answer questions below: enter image description here

In relation to this post, would it also be possible that the xticks appear every 4 xticks instead of keeping all of them, at the same time that the xticklabels are plotted every 6 xticks?, not sure about this.

1 Answers
Related