How do I change the values ​​of the axes?

3 visualizaciones (últimos 30 días)
HelpAStudent
HelpAStudent el 11 de Oct. de 2021
Respondida: Star Strider el 11 de Oct. de 2021
Hi I have this plot:
figure; errorbar(y,e,'-o')
legend('Cist -9dB', 'Cist -6dB', 'Cist -3dB', 'Cist 3dB', 'Cist 6dB', 'Cist 9dB');
xlabel('Gain');
ylabel('Grey Levels');
title('Dynamic range of 20dB');
The x axis start from 0 to 21, because I have 21 one point, how can I make the axis start from -20dB to 20dB (every 2 dB, To correspond to the first point -20dB, to the second -18 and so on: at each point increase of 2 dB up to +20)

Respuesta aceptada

Star Strider
Star Strider el 11 de Oct. de 2021
Try something like this —
x = linspace(0, 21, 25);
y = rand(size(x));
figure
plot(x, y)
xt = get(gca, 'XTick');
xtv = linspace(min(xt), max(xt), 21);
set(gca, 'XTick',xtv, 'XTickLabel',compose('%3d dB',-20:2:20))
Make appropriate changes to get the result you want.
.

Más respuestas (0)

Categorías

Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by