Highlight Region of Sine Graph

2 visualizaciones (últimos 30 días)
birdnerd007
birdnerd007 el 16 de Oct. de 2020
Editada: birdnerd007 el 16 de Oct. de 2020
I have a sine graph and I want to highlight all along the x-axis and just the [-1,1] region on the y-axis. Is this possible?
This is my code and I would like the bounds between [-1,1] on the y-axis to be shaded some color all along the x-axis. The whole area, not just the peaks and valleys.

Respuesta aceptada

Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam el 16 de Oct. de 2020
% Do you want this?
x=linspace(0,2*pi,101);
y=sin(x);
area(x,y)
  5 comentarios
Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam el 16 de Oct. de 2020
This is the next step:
x=linspace(-5*pi,5*pi,101);
KP1=(6*(sin(x)./(x)))+cos(x);
hold on;
plot(x,KP1)
plot([-5*pi,5*pi],[-1,-1],'r');
plot([-5*pi,5*pi],[1,1],'r');
birdnerd007
birdnerd007 el 16 de Oct. de 2020
Amazing! Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by