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 Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by