MATLAB Answers

how to multiply displayed xvalues on plot by constant

157 views (last 30 days)
Three One
Three One on 31 Jan 2018
Edited: Three One on 3 Jul 2020
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.


Sign in to comment.

Accepted Answer

Jos (10584)
Jos (10584) on 31 Jan 2018
Here is one approach:
% create plot
y = x.^2
% modify labels for tick marks
xticks = get(gca,'xtick')
scaling = pi
newlabels = arrayfun(@(x) sprintf('%.1f', scaling * x), xticks, 'un', 0)

More Answers (0)