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

1 visualizzazione (ultimi 30 giorni)
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)

Risposta accettata

Matt J
Matt J il 20 Lug 2023
Modificato: Matt J il 20 Lug 2023
Area = polyarea([x1;x2],[y1;y2])

Più risposte (0)

Categorie

Scopri di più su MATLAB Mobile in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by