how to fix my code and how to find the area of the regon

2 ビュー (過去 30 日間)
youssef zaki
youssef zaki 2015 年 11 月 23 日
編集済み: Carlos Guerrero García 2022 年 11 月 15 日
Consider the region inside the outer loop but outside the inner loop of the limacon r = 3 - 6 sin theta . produce a complete graph of the limacon and find the area of the region.
syms thet s
y = 3-6*sin(thet )
ezpolar(3-6*sin(thet ) , [ 0 , 2*pi] )
figure
ths = 0 : 0.01 : 2*pi ;
polar(ths , 3-6*sin(ths))
  3 件のコメント
Image Analyst
Image Analyst 2015 年 11 月 23 日
Is the inner part of the curlicue to be considered as being part of the area or excluded from the area?
Carlos Guerrero García
Carlos Guerrero García 2022 年 11 月 13 日
As the statement, the area to calculate is the green one in the following fig:

サインインしてコメントする。

回答 (2 件)

Carlos Guerrero García
Carlos Guerrero García 2022 年 11 月 14 日
移動済み: Image Analyst 2022 年 11 月 14 日
The area is 9*(pi+3sqrt(3))=75.0397..., but I wrote the following script to estimate that value via the Montecarlo method. I know that the code is not the best one, but I was only checking the result obtained by integration (in R2 or using the Green theorem)
function A=limacon(n)
outside=0;
P=[6-12*rand(n,1) 1-10*rand(n,1)]; % Choosing n random points in [-6,6]x[-9,1]
polar=[sqrt(P(:,1).^2+P(:,2).^2) atan2(P(:,2),P(:,1))+2*pi*(atan2(P(:,2),P(:,1))<0)]; % Cartesian coordenates to polar coordinates with Arg in [0,2*pi)
plot(P(:,1),P(:,2),'.','MarkerSize',10); hold on; % Ploting the random points
t=0:pi/100:2*pi; plot((3-6*sin(t)).*cos(t),(3-6*sin(t)).*sin(t),'k','LineWidth',2); % Ploting the limacon
axis([-7 7 -10 2]); axis equal;
for k=1:n; % Cheking it the point aren't in the limacon: outside the outer loop or in the inner loop
if polar(k,2)<=pi/6 && polar(k,1)>=3-6*sin(polar(k,2))
outside=outside+1;
elseif polar(k,2)>pi/6 && polar(k,2)<=5*pi/6
outside=outside+1;
elseif polar(k,2)>5*pi/6 && polar(k,2)<=7*pi/6 && polar(k,1)>=3-6*sin(polar(k,2))
outside=outside+1;
elseif polar(k,2)>7*pi/6 && polar(k,2)<=11*pi/6 && polar(k,1)>=3-6*sin(polar(k,2))
outside=outside+1;
elseif polar(k,2)>7*pi/6 && polar(k,2)<=11*pi/6 && polar(k,1)<=-6*sin(polar(k,2))-3
outside=outside+1;
elseif polar(k,2)>11*pi/6 && polar(k,1)>=3-6*sin(polar(k,2))
outside=outside+1;
end
end
A=120*(n-outside)/n; % Calculating the ratio and estimating the area

Carlos Guerrero García
Carlos Guerrero García 2022 年 11 月 15 日
編集済み: Carlos Guerrero García 2022 年 11 月 15 日
The area can be found as follows (the explanation can be found in any Calculus text. I think that here is not the right place for an extended document about. Also I don't know if you want the value, the explanation, the code, ...or all of them. If you don't find the reason of that equality in your favorite Calculus text, I don't have any problem to send an extended document with the equality):
syms t;
A=int((3-6*sin(t))^2,t,5*pi/6,13*pi/6)/2-int((3-6*sin(t))^2,t,13*pi/6,17*pi/6)/2
A = 

カテゴリ

Help Center および File ExchangeMatrix Computations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by