I don't use patches enough to know if the problem is with reducepatch or with patch in general.
The error occurs after reducepatch has calculated the reduced vertices and faces (that bit works fine), when it tries to actually update the patches faces and vertices. It uses
set(yourpatch, 'Faces', newcalculatedfaces, 'Vertices', newcalculatedvertices);
This fails when the patch already has a FaceVertexCData property that is a vector or matrix corresponding to the old face/vertices colours as in your case, because that also needs to be updated to match the new number of faces/vertices.
You have several workarounds:
- make all the faces one colour before calling reducepatch:
G.FaceColor = 'r';
reducepatch(G, 0.8);
- don't modify the existing patch with reducepatch but create a new one:
[newFaces, newVertices] = reducepatch(G, 0.8);
newG = patch('Faces', newFaces, 'Vertices', newVertices);
Either way you're losing the colours of the original patch and I'm not sure how you'd go about recreating them.
It's probably worthy of a bug report as the reducepatch doc certainly says nothing about this problem.
edit: I have filed a bug report
Best Answer