Plotting multiple polygons using lines

4 ビュー (過去 30 日間)
Tchilabalo
Tchilabalo 2020 年 10 月 13 日
コメント済み: KSSV 2020 年 10 月 13 日
I am trying to plot two polygons as shown in Figure 1. I am using the coordinates of the vertices as shown in the following code, but my plot (Figure 2) doesn't quite match Figure 1. I will appreciate any help.
clear all
X1=[28.15, 31.89, 46.22, 51.89, 55.37, 55.16, 38.49, 29.19, 28.15, 55.37, 154.84, 51.89, 55.37];% Vertices coordinates
Y1=[53.74, 66.27, 84.8, 80.83, 58.56, 58.00, 42.43, 48.6, 53.74, 58.56, 85.41, 80.83, 58.56];
X2=[28.15, 31.89, 46.22, 51.89, 55.37, 55.16, 38.49, 29.19, 28.15, 55.37, 154.84, 51.89, 55.37];
Y2=[53.74, 66.27, 84.80, 80.83, 58.56, 58.00, 42.43, 48.60, 53.74, 58.56, 85.41, 80.83, 58.56];
figure,
A =[X1.'; X2.']; B =[Y1.'; Y2.'];
plot(A,B,'LineWidth', 0.75)
xlim([0,100]);
ylim([0,100]);

採用された回答

KSSV
KSSV 2020 年 10 月 13 日
figure
hold on
patch(X1(1:8),Y1(1:8),'y','EdgeColor','k')
patch(X1(10:end),Y1(10:end),'y','EdgeColor','k')
  2 件のコメント
Tchilabalo
Tchilabalo 2020 年 10 月 13 日
Thanks for your prompt answer. For the purpose of my work, I don't want to use the "patch" function, but instead plot the polygons using lines.
KSSV
KSSV 2020 年 10 月 13 日
figure
hold on
plot(X1(1:8),Y1(1:8),'k')
plot(X1(10:end),Y1(10:end),'k')

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeElementary Polygons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by