shade area under curve between 2 x-axis limits

16 次查看(过去 30 天)
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?

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2015-7-26
编辑:Azzi Abdelmalek 2015-7-26
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]);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Curve Fitting Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by