riemann sum for area of circle with range x and equation of the circle
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Antworten (1)
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
0 Kommentare
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!