Matlab x axis label set as vector

How to set x axis label as vector? For example, if I make a graph (1: 5), the x-axis label is [1, 2, 3, 4, 5]. I would like to set it to a vector, for example. [1 4 5 7 10]. Please note that the size of the vector can be huge, so doing it manually is not permissible.

+3
source share
2 answers

I believe that this is what you want.

y = 1:5; x = [1 4 5 7 10]; plot(y); set(gca,'XTickLabel',x); 
+2
source

you can do this by sending plot two vectors: one for x and one for y.

 plot([1 4 5 7 10], 1:5); 
+1
source

All Articles