필터 지우기
필터 지우기

Problem using Reducepatch command

조회 수: 3 (최근 30일)
Basheer Alwaely
Basheer Alwaely 2018년 3월 11일
댓글: Basheer Alwaely 2018년 3월 12일
Hi,
For a given W (n,3), where W contains the x,y,z coordinates of n-nodes.
tri=delaunay(W(:,1),W(:,2));
G = trisurf(tri,W(:,1),W(:,2),W(:,3)); % to convert x,y,z into patch.
I used patch G, where
FaceColor: 'flat'
FaceAlpha: 1
EdgeColor: [0 0 0]
LineStyle: '-'
Faces: [380x3 double]
Vertices: [200x3 double],
and the command is :
reducepatch(G,0.8)
I got a problem with the reducepatch command
"Warning: Error creating or updating Patch Error in value of property
FaceVertexCData... Number of colors must equal number of vertices or faces".
Any idea? how to solve it? .... many thanks.
  댓글 수: 4
Guillaume
Guillaume 2018년 3월 12일
Can you provide your W array, so we can investigate?
Basheer Alwaely
Basheer Alwaely 2018년 3월 12일
편집: Basheer Alwaely 2018년 3월 12일
Sure, I uploaded it above.
Cheers

댓글을 달려면 로그인하십시오.

채택된 답변

Guillaume
Guillaume 2018년 3월 12일
편집: Guillaume 2018년 3월 12일
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'; %for example
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
  댓글 수: 1
Basheer Alwaely
Basheer Alwaely 2018년 3월 12일
My problem has been solved, Many thanks Guillaume

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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