Colour Segments of graph

5 visualizaciones (últimos 30 días)
Michael Constantine
Michael Constantine el 10 de Sept. de 2020
Respondida: Monisha Nalluru el 14 de Sept. de 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 comentario
KSSV
KSSV el 10 de Sept. de 2020
Read about fill, patch.

Iniciar sesión para comentar.

Respuestas (1)

Monisha Nalluru
Monisha Nalluru el 14 de Sept. de 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