how to have a variable axis in matlab
33 views (last 30 days)
Show older comments
I have measurements every 0.1 metres for points 1-470, then measurements every 0.05 metres for points 470-530. How can I change these to reflect their values in space? (the first 470 points measure from a distance of 0 to 47 metres, whereas the last 60 points measure a distance of 47 to 50 metres). I would like for the scale to be uniform from 0-50 metres, even though for the last 3 metres the points are more frequent than in the first 47 metres.
I have tried using x-ticks, but this does not reflect that the final 60 points are in a more condensed space than the first 470.
Thank you
2 Comments
Jan
on 1 Apr 2019
Please post which code you have tried and explain, what you want to achieve. What does "change these to reflect their values in space" mean? How should what be reflected?
Answers (1)
Jan
on 1 Apr 2019
Edited: Jan
on 1 Apr 2019
Do not change only the XTicks, but adjust the X-values also:
x = [1, 2, 3, 4, 5, 5.1, 5.2, 5.3, 5.4, 5.5]
y = rand(size(x));
subplot(1,2,1)
plot(y)
subplot(1,2,2)
plot(x, y) % <== Use 2 inputs to define the x-values also
Without specifying the X-values, Matlab assumes, that they are 1:numel(y).
0 Comments
See Also
Categories
Find more on Subplots 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!