Effacer les filtres
Effacer les filtres

color area between functions

2 vues (au cours des 30 derniers jours)
Nora Al Allaf
Nora Al Allaf le 28 Oct 2020
Commenté : Akira Agata le 28 Oct 2020
Hi,
I have two functions g = exp(-x.^2./2) and h = x.^2-3.*x+2;
there is a region enclosed between them, between x=0 and x=3
I wanna color it using fill
how to? =)

Réponse acceptée

David Hill
David Hill le 28 Oct 2020
x = -1:.01:4;
g = exp(-x.^2./2);
h = x.^2-3.*x+2;
plot(x, g, 'r', 'LineWidth', 2);
hold on;
plot(x, h, 'b', 'LineWidth', 2);
x=.43:.01:2.08;
x2 = [x, fliplr(x)];
g = exp(-x.^2./2);
h = x.^2-3.*x+2;
inBetween = [g, fliplr(h)];
fill(x2, inBetween, 'g');
  1 commentaire
Akira Agata
Akira Agata le 28 Oct 2020
+1
Also, this blog post will be helpful for this topic:

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by