Re-indexing matrix which corresponds to mesh
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello
I'm wondering if anyone can help me. I'm trying to re-index two matrixes. I have selected a sub-sample of data and I need them to be re-numbered to 1:N. There is a corresponding matrix which is an Mx3 matrix which makes up the triangles.
I need to re-number the first matrax and then apply that re-numbered matrix to the list of triangles. This cannot be done by simple indexing because the numbers in the original matrix are obviously changed so they do not correspond with values in the 2nd matrix.
I'm not sure if I've explained that well but here is an example of the matrices I currently have.
I would also like to point out that those are just a sample number, the nodes may not necessarily match up below but they do in my matrices.
Cheers :)
Nodes:
3772
3947
3948
3949
4144
4145
4146
4147
4148
4149
Tri:
3771 3772 3603
3604 3603 3772
3773 3604 3772
3771 3946 3947
3948 3771 3947
3771 3948 3772
3772 3948 3949
3772 3949 3950
3772 3950 3773
3947 3946 4143
댓글 수: 7
채택된 답변
추가 답변 (1개)
Andrei Bobrov
2017년 6월 12일
편집: Andrei Bobrov
2017년 6월 12일
Node_out = (1:numel(Node))';
[~,Triangles_out] = ismember(Triangles,Node);
or
[v,~,Node_out] = unique(Node,'stable');
Triangles_out = ismember(Triangles,v);
댓글 수: 2
Sterling Baird
2021년 5월 7일
Triangles_out is your new, renumbered triangulation. This is great, thank you! Neat application of ismember()
참고 항목
카테고리
Help Center 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!