Two colors, one vector
조회 수: 5 (최근 30일)
이전 댓글 표시
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
채택된 답변
Azzi Abdelmalek
2013년 7월 16일
편집: Azzi Abdelmalek
2013년 7월 16일
x = -4*pi:0.001:4*pi;
y=sin(x);
y2=y;
y2(y2>=0)=nan;
plot(x,y ,'r',x,y2,'g');
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!