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

5 views (last 30 days)
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?

Accepted Answer

Robert U
Robert U on 18 Apr 2018

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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!