Why does "patch(X,Y,Z, FaceColor=C)" result in thin lines rather than full patches?
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 31 Okt. 2025 um 0:00
Beantwortet: MathWorks Support Team
am 31 Okt. 2025 um 18:35
When calling "patch" with the following syntax:
>> patch(X, Y, Z, 'FaceColor', C)
MATLAB interprets "Z" as the color, and displays straight lines rather than the full patches.
Why does this happen?
Akzeptierte Antwort
MathWorks Support Team
am 31 Okt. 2025 um 0:00
This behavior is expected. MATLAB expects all positional arguments to come before Name-Value arguments. You can either call "patch" and specific a color by using:
>> patch(X,Y,Z,C)
or
>> patch('XData', X, 'YData', Y, 'ZData', Z, 'FaceColor', C)
The problem with the following code
>> patch(input1, input2, input3, 'FaceColor', input4) % (the incorrect syntax resulting in thin lines)
is that the arguments are interpreted by MATLAB as
>> patch(X, Y, C, 'FaceColor', C)
"input3" being interpreted as "C" since MATLAB expects either the positional arguments (X,Y,Z,C) or (X,Y,C) before Name-Value arguments when using the syntax "patch(___, Name, Value)". There is no (X,Y,Z) syntax that can precede the Name-Value arguments.
Please refer to the documentation on "patch" for more details.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Polygons finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!