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

1 回表示 (過去 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])
  1 件のコメント
Dr Sohaib Khan
Dr Sohaib Khan 2023 年 7 月 20 日
Thankyou soooooooooo much Matt. :) :) :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by