R2015a plot problem with ticklabel definition
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
figure % new figure
[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);
title('Multiple Decay Rates')
xlabel('Time (\musec)')
ylabel(hAx(1),'Slow Decay') % left y-axis
set(hAx(1),'ytick',-200:50:200)
set(hAx(2),'ytick',linspace(-0.8,0.8,5),'YTickLabel',num2str(y2(:), '%0.1f'))
When I run this, I get only positive values for the y axis on the right and the values aren't correct. Any solution??
0 commentaires
Réponses (2)
Walter Roberson
le 21 Fév 2020
Modifié(e) : Walter Roberson
le 21 Fév 2020
You only ask for 5 ticks in your linspace, with labels derived from y2 not from what you linspace. Your first 5 y2 values are all positive.
6 commentaires
Spencer Chen
le 21 Fév 2020
Well, you have set you ytick labels to:
num2str(y2(:), '%0.1f')
Maybe you meant?
num2str(linspace(-0.8,0.8,5), '%0.1f')
Blessings,
Spencer
Voir également
Catégories
En savoir plus sur Visual Exploration 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!