Patch - Not enough input arguments

조회 수: 5 (최근 30일)
Axel Sopp
Axel Sopp 2019년 4월 21일
답변: Geoff Hayes 2019년 4월 21일
I am trying to create a rectangle where the sides all have different colors. I found another question asking about this, but the answer there didn't seem to work. This is the code I'm trying to run:
X = [0,1,1,0];
Y = [0,0,2,2];
C = [1,0,0;0,1,0;0,0,1;1,1,0];
patch(X,Y,'FaceVertexCData',C,'EdgeColor','flat','FaceColor','none','LineWidth',2)
Yet I always get this error message:
Error using patch
Not enough input arguments.
I don't understand what inputs are missing here. How do I fix this?

답변 (1개)

Geoff Hayes
Geoff Hayes 2019년 4월 21일
Axel - from patch you need to either provide a C the polygon colour specified as a scalar, vector, matrix, or a color name which may be the C you are passing in for the FaceVertextCData propery (though you may observe another error if you try to use this C for the polygon colour). Or you can just do
patch('XData', X, 'YData', Y, 'FaceVertexCData',C,'EdgeColor','flat','FaceColor','none','LineWidth',2)

카테고리

Help CenterFile Exchange에서 Polygons에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by