How can i find inside area of the geometry (2d) ??

조회 수: 3 (최근 30일)
Dr Sohaib Khan
Dr Sohaib Khan 2023년 7월 20일
댓글: Dr Sohaib Khan 2023년 7월 20일
Hello everyone... can anyone please help me and educated me. I want to find the area covered inside this 2d geometry ?? Please let me know how to do it. I shall remain thankful. Please see the code attached.
clc
clear all
close all
t1 = 0:pi/100:pi; % Top curve 0 to 180 deg
t2 = -pi:pi/100:0; % Bottom curve 180 to -180 deg
%%% Shape
a1 = 375; % width, x-axis
a2 = 375;
b1 = 457; % height, y-axis
b2 = 78;
%%% Slope
n1 = -1.43;
m1 = 1.25;
n2 = -1.0;
m2 = 1.6;
x1 = zeros(length(t1),length(n1));
y1 = x1;
z1 = x1*0
z1 = 101×1
0 0 0 0 0 0 0 0 0 0
leg1 = cell(length(n1),1);
x2 = zeros(length(t2),length(n2));
y2 = x2;
z2 = x2*0
z2 = 101×1
0 0 0 0 0 0 0 0 0 0
leg2 = cell(length(n2),1);
for i=1:length(n1)
x1(:,i) = sign(cos(t1)).*a1.*abs(cos(t1)).^(2+n1(i));
y1(:,i) = sign(sin(t1)).*b1.*abs(sin(t1)).^(2+m1(i));
leg(i) = {['n1 = ',num2str(n1(i))]};
end
for i=1:length(n2)
x2(:,i) = sign(cos(t2)).*a2.*abs(cos(t2)).^(2+n2(i));
y2(:,i) = sign(sin(t2)).*b2.*abs(sin(t2)).^(2+m2(i));
leg(i) = {['n2 = ',num2str(n2(i))]};
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(1)
xlabel('X-axis','fontweight','bold','fontsize',10)
ylabel('Y-axis','fontweight','bold','fontsize',10)
zlabel('Z-axis','fontweight','bold','fontsize',10)
plot3(z1,x1,y1,z2,x2,y2,'linewidth',2)

채택된 답변

Matt J
Matt J 2023년 7월 20일
편집: Matt J 2023년 7월 20일
Area = polyarea([x1;x2],[y1;y2])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Mobile에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by