Manipulate values on axes MATLAB

I am plotting a graph, and the plot that I want is between 2000 and 2010 seconds on the x axis. Although I want the plot to be between these values, I would like the x-axis on the plot to be between 0 and 10 seconds. In other words still have the same plot (the y-axis values between that are in the range 2000-2010 seconds), but manipulate the values on the x-axis to show a lower value. Does anyone know if this is possible? I am using Matlab R2015b.

 Accepted Answer

Adam
Adam on 4 Dec 2015
Edited: Adam on 4 Dec 2015
When you call plot you can pass in x data and y data. These can be anything you want so just set one to be 2000 to 2010 and the other to be 0 to 10 if that is what you are trying to do.
e.g.
figure; hAxes = gca;
plot( hAxes, 0:10, 2000:2010 )
The x or y data can obviously be manipulated subsections of some other array also.

4 Comments

Thank you for answering, but I probably didn't describe my problem too well. I have a system that is stabilized after 2000 seconds. Therefore I plot my graph from 2000 to 2010 seconds. But I want it to look like the system was stable after 0 seconds, hence I want the print on the x-axis to say from 0 to 10, although the plotted values are in the time from 2000-2010 seconds. Do you understand my problem better now? Is there any way to do this?
This will still allow you to do that.
Take your times and subtract 2000 from them to plot as x.
Aha, thank you, it worked! But if I want to simulate and thus plot e.g. from 2400-3100 seconds, meaning that I want 0-700 to be written on the x-axis, it says 0-7 instead of 0-700... I used the code you wrote and set(gca, 'XTickLabel', 0:700) from Thorsten under here. Do you know how I can get the x-axis to say 0-700?

Sign in to comment.

More Answers (1)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!