How do I add colour to the faces of a patched shape

4 ビュー (過去 30 日間)
Jacob Vialou-Clark
Jacob Vialou-Clark 2018 年 4 月 17 日
コメント済み: Jacob Vialou-Clark 2018 年 4 月 18 日
figure(1)
v = [0 -20 60; 0 -20 56; 50 -10 60; 50 -10 56; 55 0 60; 55 0 56; -55 0 60; -55 0 56; -50 -10 60; -50 -10 56];
f = [1 2 4 3; 3 4 6 5; 5 6 8 7; 7 8 10 9; 1 2 10 9];
patch('Faces',f,'Vertices',v,'FaceAlpha',0);
I have this shape which is a simplified wing, how can I adapt the patch function to colour the faces?

採用された回答

Robert U
Robert U 2018 年 4 月 18 日

Hello Jacob Cialou-Clark:

as you specify a 3D faced object you have to take care which vertices you connect to faces. Right now, you define the mantle which cannot be seen directly from 2D plot via patch(). Another problem is that 'FaceAlpha',0 represents completely transparent faces.

In order to change that and have all faces of your 3D wing in 'red' you can change your code to:

 fh = figure(1);
 ah = axes('Parent',fh);
 v = [0 -20 60; 0 -20 56; 50 -10 60; 50 -10 56; 55 0 60; 55 0 56; -55 0 60; -55 0 56; -50 -10 60; -50 -10 56];
 f = [1 2 4 3 1; 3 4 6 5 3; 5 6 8 7 5; 7 8 10 9 7; 1 2 10 9 1; 1 3 5 7 9; 2 4 6 8 10];
 patch(ah,'Faces',f,'Vertices',v,'FaceAlpha',1,'FaceColor','red');
 ah.View = [45 45];

Kind regards,

Robert

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by