开发者

matlab x axis label set as a vector

开发者 https://www.devze.com 2023-03-31 16:17 出处:网络
How can I set the x axis label as a vector? For example, if I do plot(1:5), the x axis label is [1, 2, 3, 4, 5]. I\'d like to set it to a vector, e.g. [1 4 5 7 10]. Note that the vector\'s size may be

How can I set the x axis label as a vector? For example, if I do plot(1:5), the x axis label is [1, 2, 3, 4, 5]. I'd like to set it to a vector, e.g. [1 4 5 7 10]. Note that the vector's size may be huge, so doing开发者_StackOverflow it manually is not acceptable.


I believe this is what you want.

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


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

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号