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

1 次查看(过去 30 天)
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
As the statement, the area to calculate is the green one in the following fig:

请先登录,再进行评论。

回答(2 个)

Carlos Guerrero García
移动: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
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 CenterFile Exchange 中查找有关 Matrix Computations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by