How to plot an area limited by two functions?
Mostrar comentarios más antiguos
Hello everybody, so i am currently trying to figure out how to color an area inside my plot.
figure;
hold on;
wavelenght = 1520:0.1:1580;
power = (cos((wavelenght-1520)/60*pi)+1)/2;
wl = 1545:0.1:1555;
p = sin((wl-1545)/10*pi);
%Plot 1 ----------------------------
subplot(1,2,1)
plot(wavelenght,power,wavelenght,1-power,wl,p);
xlabel('Wavelengh [nm]');
ylabel('Power transmission');
%Plot 2 ----------------------------
subplot(1,2,2)
hold on;
plot(wavelenght,power,wavelenght,1-power,wl,p);
xlabel('Wavelengh [nm]');
ylabel('Power transmission');
My code currently shows 2 same plots and the goal is to color the area marked green in the picture below

I've tried the fill-command but since the area is limited by a function on the x-Axis and the y-Axis it does not work for me. Any suggestions would be helpful. Thank you.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

