shade area under curve between 2 x-axis limits

16 vues (au cours des 30 derniers jours)
monkey_matlab
monkey_matlab le 26 Juil 2015
For the code below:
x=0:pi/50:2*pi;
y1=x.^2;
baseval1=20;
baseval2=3;
clf;
H1=area(x,y1,baseval1);
H=area(x,y1);
set(H(1),'FaceColor',[1 0.5 0]);
how do I shade the area under the curve just between x = 3 to x = 4?

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 26 Juil 2015
Modifié(e) : Azzi Abdelmalek le 26 Juil 2015
x=0:pi/50:2*pi;
y1=x.^2;
H1=area(x,y1);
hold on
idx=x>3&x<4;
H=area(x(idx),y1(idx));
set(H(1),'FaceColor',[1 0.5 0]);
Or
close
x=0:pi/50:2*pi;
y1=x.^2;
%baseval1=20;
%baseval2=3;
%clf;
H1=area(x,y1,'FaceColor',[1 1 1]);
hold on
idx=x>3&x<4;
H=area(x(idx),y1(idx));
set(H(1),'FaceColor',[1 0.5 0]);

Plus de réponses (0)

Catégories

En savoir plus sur Curve Fitting Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by