Two colors, one vector
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I would like to plot a periodic vector, such as
x = -4*pi:0.1:4*pi;
plot(sin(x));
but to have the positive values plotted in one color and the negative values are plotted in another. Is there a simple, elegant way to do this?
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 16 Juil 2013
Modifié(e) : Azzi Abdelmalek
le 16 Juil 2013
x = -4*pi:0.001:4*pi;
y=sin(x);
y2=y;
y2(y2>=0)=nan;
plot(x,y ,'r',x,y2,'g');
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots 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!