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

조회 수: 4 (최근 30일)
sirihaas gaddipati
sirihaas gaddipati 2020년 3월 12일
편집: sirihaas gaddipati 2020년 3월 22일
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개)

Raynier Suresh
Raynier Suresh 2020년 3월 18일
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

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by