creatting a polygon in matlab

3 ビュー (過去 30 日間)
Mili Kian
Mili Kian 2020 年 10 月 4 日
コメント済み: Matteo Lo Preti 2020 年 10 月 4 日
hi
im going to create a polygon that is combination with points and function.
look at this picture
fourmula of top function is : y = 10+1*exp((-(x-15).^2)/10);
i want to creat a polygon the hatched figured
please help, thanks

採用された回答

Matteo Lo Preti
Matteo Lo Preti 2020 年 10 月 4 日
x = linspace(0,30,50);
y = 10+1*exp((-(x-15).^2)/10);
x = [30 30 0 x];
y = [10 0 0 y];
warning('off', 'MATLAB:polyshape:repairedBySimplify')
polygon = polyshape(x,y);
figure;
plot(polygon);
  2 件のコメント
Mili Kian
Mili Kian 2020 年 10 月 4 日
thanks alot.
and im sorry,
i have another question i have a lot of points and i want to find if this points is in polygon or not ?
my points are:
X Y
0.50000000 0.50000000
0.50000000 1.5000000
0.50000000 2.5000000
0.50000000 3.5000000
0.50000000 4.5000000
0.50000000 5.5000000
0.50000000 6.5000000
0.50000000 7.5000000
0.50000000 8.5000000
0.50000000 9.5000000
0.50000000 10.500000
0.50000000 11.500000
0.50000000 12.500000
0.50000000 13.500000
0.50000000 14.500000
0.50000000 15.500000
1.5000000 0.50000000
1.5000000 1.5000000
1.5000000 2.5000000
1.5000000 3.5000000
1.5000000 4.5000000
1.5000000 5.5000000
1.5000000 6.5000000
1.5000000 7.5000000
1.5000000 8.5000000
1.5000000 9.5000000
1.5000000 10.500000
1.5000000 11.500000
1.5000000 12.500000
1.5000000 13.500000
1.5000000 14.500000
1.5000000 15.500000
2.5000000 0.50000000
2.5000000 1.5000000
2.5000000 2.5000000
2.5000000 3.5000000
2.5000000 4.5000000
2.5000000 5.5000000
2.5000000 6.5000000
2.5000000 7.5000000
2.5000000 8.5000000
2.5000000 9.5000000
2.5000000 10.500000
2.5000000 11.500000
2.5000000 12.500000
2.5000000 13.500000
2.5000000 14.500000
2.5000000 15.500000
3.5000000 0.50000000
3.5000000 1.5000000
3.5000000 2.5000000
3.5000000 3.5000000
3.5000000 4.5000000
3.5000000 5.5000000
3.5000000 6.5000000
3.5000000 7.5000000
3.5000000 8.5000000
3.5000000 9.5000000
3.5000000 10.500000
3.5000000 11.500000
3.5000000 12.500000
3.5000000 13.500000
3.5000000 14.500000
3.5000000 15.500000
4.5000000 0.50000000
4.5000000 1.5000000
4.5000000 2.5000000
4.5000000 3.5000000
4.5000000 4.5000000
4.5000000 5.5000000
4.5000000 6.5000000
4.5000000 7.5000000
4.5000000 8.5000000
4.5000000 9.5000000
4.5000000 10.500000
4.5000000 11.500000
4.5000000 12.500000
4.5000000 13.500000
4.5000000 14.500000
4.5000000 15.500000
5.5000000 0.50000000
5.5000000 1.5000000
5.5000000 2.5000000
5.5000000 3.5000000
5.5000000 4.5000000
5.5000000 5.5000000
5.5000000 6.5000000
5.5000000 7.5000000
5.5000000 8.5000000
5.5000000 9.5000000
5.5000000 10.500000
5.5000000 11.500000
5.5000000 12.500000
5.5000000 13.500000
5.5000000 14.500000
5.5000000 15.500000
then what am i do?
Matteo Lo Preti
Matteo Lo Preti 2020 年 10 月 4 日
Hi, have a look at the inpolygon function!

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

その他の回答 (1 件)

Alan Stevens
Alan Stevens 2020 年 10 月 4 日
You could also use the patch function
x = [0 0:30 30 0];
y = [0 10+exp((-(x(2:end-2)-15).^2)/10) 0 0];
patch(x,y,'r')

カテゴリ

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