Why does "patch(X,Y,Z, FaceColor=C)" result in thin lines rather than full patches?
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 31 Ott 2025 alle 0:00
Risposto: MathWorks Support Team
il 31 Ott 2025 alle 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?
Risposta accettata
MathWorks Support Team
il 31 Ott 2025 alle 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Polygons in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!