Dear all,
i am stuck with a small (easy) problem and need a hint.
Consider you have a non-unique element list t_quad with size(n_quad,4) and a corresponding non-unique point list p_quad with size(n_points,2).
Moreover, the point list also contains points which are never indexed by the element list.
I want to make both lists unique meaning i want to have a t_quad_unique list and a p_quad_unique list:
% Works!: This removes the non-unique elements and the corresponding points
[t_quad,~,~]=unique(t_quad,'rows');
[p_quad,~,b]=unique(p_quad,'rows');
t_quad(:)=b(t_quad(:));
Then after this i want to remove also the non-used points which are never used by the element list:
% Does not work!
[p_quad,~,b]=unique(p_quad(t_quad(:),:),'rows');
t_quad(:)=b(t_quad(:));
I lose some informations in this step. Where is the mistake?
Thanks for your help!
Edit:
Before:
After:

댓글 수: 6

madhan ravi
madhan ravi 2020년 7월 8일
A minimum working example would help. Explicitly show how your expected result should look like a particular matrix.
ConvexHull
ConvexHull 2020년 7월 8일
See edited post, i have supplied a mat-file.
ConvexHull
ConvexHull 2020년 7월 8일
편집: ConvexHull 2020년 7월 8일
To generate the minimal example i have applied this to the unique lists. With this i have made the lists non-unique and added random points.
p_quad=[p_quad;p_quad;rand(20,2)];
t_quad=[t_quad;t_quad];
ConvexHull
ConvexHull 2020년 7월 8일
편집: ConvexHull 2020년 7월 8일
Use this as visualization:
for i_quad=1:size(t_quad,1)
plot([p_quad(t_quad(i_quad,:),1);p_quad(t_quad(i_quad,1),1)],...
[p_quad(t_quad(i_quad,:),2);p_quad(t_quad(i_quad,1),2)])
if(i_quad==1)
hold on;
end
end
ConvexHull
ConvexHull 2020년 7월 8일
편집: ConvexHull 2020년 7월 8일
Note that the minimal example is quite specific. The non-used random points may be located arbitrary in the point list.
ConvexHull
ConvexHull 2020년 7월 8일
편집: ConvexHull 2020년 7월 8일
Note that the point ordering inside an element
t_quad(:,1) --> t_quad(:,2) --> t_quad(:,3) --> t_quad(:,4)
should be preserved.

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

 채택된 답변

ConvexHull
ConvexHull 2020년 7월 8일
편집: ConvexHull 2020년 7월 8일

0 개 추천

I answer my own question. This should work:
[t_quad,~,~]=unique(t_quad,'rows');
[p_quad,~,b]=unique(p_quad,'rows');
t_quad(:)=b(t_quad(:));
[p_unique,~,~]=unique(p_quad(t_quad(:),:),'rows');
[~,c]=ismember(p_quad,p_unique,'rows');
p_quad=p_unique;
t_quad(:)=c(t_quad(:));
Thanks anyway!

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2020년 7월 8일

편집:

2020년 7월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by