riemann sum for area of circle with range x and equation of the circle
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
r=10;
ezplot(@(x,y) (x).^2 +(y).^2 -r^2, [-10,10]);
axis equal
%title "circle centered at (0,0) with radius of 10"
dx=4;
x=-10:dx:10;
y=(100-(x).^2).^(1/2);
sum=sum(2*y*dx);
1 comentario
Respuestas (1)
Raynier Suresh
el 18 de Mzo. de 2020
To find area using riemann sum you could use the following code,
r = 10; % Radius
x = -r:0.01:r; % Range of x
y = sqrt(r*r - x.*x); % y = f(x)
Area = 2*sum(y) % sum(y) will give the area of semi circle
plot(x,y);hold on;plot(x,-1*y);
To solve using integration directly,
r = 10; % radius
y = @(x)sqrt(r.*r - x.*x); % y = f(x) as function handle
Xmin = 0;
Xmax = r;
area = 4*integral(y,Xmin,Xmax) % Xmin and Xmax correspond to the first quarter of circle
0 comentarios
Ver también
Categorías
Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!