Quadrature rectangles transparency in plot
2 views (last 30 days)
Show older comments
Hi,
How can I change the transparency of the rectangles?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278644/image.png)
function [I]=bobby_85(n) % n=30; n=300;
p=1;
h=1/(n-1);
I=0;
x=0;
xv=linspace(0,1,n);
close(figure(1))
figure(1)
axis([0 1 0 1])
plot(xv,f(xv),'k')
hold on
for i=1:n-1
I=I+h*f(x);
figure(1)
plot(x,f(x),'r.','MarkerSize',10)
x=x+h;
pause(3/n^p)
end
plot(1,f(1),'r.','MarkerSize',10)
pause(3/n^p)
x=0;
for i=1:n-1
figure(1)
plot([x x],[0 f(x)],'b')
plot([x x+h],[f(x) f(x)],'b')
pause(3/n^p)
plot([x+h x+h],[0 f(x)],'b')
pause(3/n^p)
area([x x+h],[f(x) f(x)])
x=x+h;
pause(3/n^p)
end
title(['n=', num2str(n)])
text(0.1, 0.8, ['integral=',num2str(I,16)])
hold off
function [y]=f(x)
% y=exp(-x.^2);
% y=x.*sin(x);
% y=x+sin(x);
% y=x;
% y=x.^2;
y=0.2+x.*sin(10*x);
end
end
0 Comments
Answers (0)
See Also
Categories
Find more on Visual Exploration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!