riemann sum for area of circle with range x and equation of the circle

4 Ansichten (letzte 30 Tage)
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);

Antworten (1)

Raynier Suresh
Raynier Suresh am 18 Mär. 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

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by