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

42 vues (au cours des 30 derniers jours)
MUDASIR MALIK
MUDASIR MALIK le 7 Avr 2022
Commenté : MUDASIR MALIK le 10 Avr 2022
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

Réponses (1)

Dave B
Dave B le 7 Avr 2022
Modifié(e) : Dave B le 7 Avr 2022
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])
  1 commentaire
MUDASIR MALIK
MUDASIR MALIK le 10 Avr 2022
Thanks for giving the best suggestions.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Object Properties dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by