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

조회 수: 3 (최근 30일)
HelpAStudent
HelpAStudent 2021년 10월 11일
답변: Star Strider 2021년 10월 11일
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)

채택된 답변

Star Strider
Star Strider 2021년 10월 11일
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.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by