Filter löschen
Filter löschen

shade area under curve between 2 x-axis limits

8 Ansichten (letzte 30 Tage)
monkey_matlab
monkey_matlab am 26 Jul. 2015
Bearbeitet: Azzi Abdelmalek am 26 Jul. 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?

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 26 Jul. 2015
Bearbeitet: Azzi Abdelmalek am 26 Jul. 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]);

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by