MATLAB: Change scaling of x-axis

MATLABrescale x-axis

I have data in IDCount(1,:) that goes from 0 to, say, 260. I want to rescale so the x-axis will appear in seconds — IDCount(1,:)/140. Cannot see how to do this

Best Answer

Try this:
x = 0:260; % Create Data

y = rand(size(x)); % Create Data
figure(1)
plot(x, y)
xt = get(gca, 'XTick'); % 'XTick' Values
set(gca, 'XTick', xt, 'XTickLabel', xt/140) % Relabel 'XTick' With 'XTickLabel' Values
The set call relabels the 'XTick' values with the same values divided by 140.