I want to have specific values on y-axis of the plot.

조회 수: 39 (최근 30일)
MUDASIR MALIK
MUDASIR MALIK 2022년 4월 7일
댓글: MUDASIR MALIK 2022년 4월 10일
clc, clear, close all
u = 0.2;
for n = 1:40
v(n) = (41/81)*u + 20/81;
u = v(n);
end
plot(1:40,v,'.-','LineWidth',1,'color','b')
hold on

답변 (1개)

Dave B
Dave B 2022년 4월 7일
편집: Dave B 2022년 4월 7일
To set the y tick values, you can use the YTick property on the Axes. You can use gca and set to apply these to the current axes:
u = 0.2;
for n = 1:40
v(n) = (41/81)*u + 20/81;
u = v(n);
end
plot(1:40,v,'.-','LineWidth',1,'color','b')
set(gca,'YTick',[.35 .4 .42 .44 .46 .5])
Alternatively, you can just use the convenient yticks function:
figure
plot(1:40,v,'.-','LineWidth',1,'color','b')
yticks([.35 .36 .4 .42 .43 .45])

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by