How to Rescale X Axis in Plot
Show older comments
Hi,
I'm plotting a 1470x28 double and I need to rescale the x axis. Right now, the x axis shows data from 0 to 1470, but I need to convert the units of the x axis so that they show the same data, but it says 0 to 2940 instead. Basically i just want the 1500 on the bottom right to become 3000 and I want the data to still extend to the 3000 tick. I attached a pic of what I currently have. Thanks. 

Accepted Answer
More Answers (1)
Maybe this example will show you how you can do that.
First, I'll create a random matrix the same size as yours:
y = rand(1470,28);
And plot it like you are doing now (maybe):
subplot(3,1,1)
plot(y)
title('plot(y)')
That plots y against the sample numbers 1:1470.
Another way to do that is to explicitly use those numbers as x (the first argument) in plot:
subplot(3,1,2)
plot(1:1470,y) % same as first plot
title('plot(x,y)')
If you do it that way, then you can make x whatever you want (in this case, multiplying by 2):
subplot(3,1,3)
plot(2*(1:1470),y) % doubling x
title('plot(2*x,y)')
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

