How to plot discrete values on the x-axis.

15 views (last 30 days)
Hello everybody,
I haven't figured out yet how can I plot discrete values along the x-axis. I need to plot for instance:
y= [10 1 2 3 20 22 20 10 14 12];
x = [89 89 89 89 89 89 89 90 91 10];

Accepted Answer

Ameer Hamza
Ameer Hamza on 13 Oct 2020
Edited: Ameer Hamza on 13 Oct 2020
Try this
y = [10 1 2 3 20 22 20 10 14 12];
x = [89 89 89 89 89 89 89 90 91 10];
ax = axes();
plot(y, 'r+', 'MarkerSize', 10, 'LineWidth', 2)
ax.XTickLabel = string(x);
  8 Comments
DAVIDE DELLA VALLE
DAVIDE DELLA VALLE on 13 Oct 2020
Nope, it was just an example. I am dealing with vectors much bigger than these.
Ameer Hamza
Ameer Hamza on 13 Oct 2020
But the same method will apply there.

Sign in to comment.

More Answers (0)

Categories

Find more on Line Plots 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!