Colour Segments of graph

6 Ansichten (letzte 30 Tage)
Michael Constantine
Michael Constantine am 10 Sep. 2020
Beantwortet: Monisha Nalluru am 14 Sep. 2020
I have plotted a voltage vs time graph and wish to colour sections of it, and want to know the best way to do this? I will attach a screenshot of the graph I have plotted and an example of how I wish to colour it.
Cheers
  1 Kommentar
KSSV
KSSV am 10 Sep. 2020
Read about fill, patch.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Monisha Nalluru
Monisha Nalluru am 14 Sep. 2020
fill, patch functions are used to fill the area under a plot
As an example, you can refer to the following code
x1=0:pi/20:pi;
y1=sin(x1);
patch(x1,y1,'r')
x2=pi:pi/20:2*pi;
y2=sin(x2);
patch(x2,y2,'b')
x3=2*pi:pi/20:3*pi;
y3=sin(x3);
patch(x3,y3,'y');
hold on
x=pi/60:pi/20:pi;
y=sin(x);
fill(x,y,'k') // color some red area by black
hold off

Community Treasure Hunt

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

Start Hunting!

Translated by