how to multiply displayed xvalues on plot by constant

28 visualizaciones (últimos 30 días)
Three One
Three One el 31 de En. de 2018
Comentada: Rik el 17 de Ag. de 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.

Respuesta aceptada

Jos (10584)
Jos (10584) el 31 de En. de 2018
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)
  3 comentarios
Maitrayee Ghosh
Maitrayee Ghosh el 17 de Ag. de 2020
This code shows some errors in the last line with delimiters.
Rik
Rik el 17 de Ag. de 2020
@Maitrayee Ghosh what exact code are you using and what is the complete error message?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by