how to multiply displayed xvalues on plot by constant
29 次查看(过去 30 天)
显示 更早的评论
How can I change the the display, that is the way the x values look on the plot (not the x-values themselves in the code - just the way they look) to multiply them by a constant. Kind of like scaling.
0 个评论
采纳的回答
Jos (10584)
2018-1-31
Here is one approach:
% create plot
x=-10:2:10
y = x.^2
plot(x,y,'bo-')
% modify labels for tick marks
xticks = get(gca,'xtick')
scaling = pi
newlabels = arrayfun(@(x) sprintf('%.1f', scaling * x), xticks, 'un', 0)
set(gca,'xticklabel',newlabels)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!