How can I pick certain element from each row of an array ?

조회 수: 1 (최근 30일)
kiet tran
kiet tran 2019년 11월 9일
댓글: kiet tran 2019년 11월 15일
I already have an array CF [ 1 2 3; 2 3 4]
How can I create an for loop that give me an array CE [ 1 2; 2 3; 3 1; 3 4; 4 2] ?
Each row of CF represent a face of an triangle. Each row of CE represents the edges of the face.
Thank you
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 11월 9일
I cannot tell what your rule is for constructing the edges?

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

채택된 답변

Fabio Freschi
Fabio Freschi 2019년 11월 9일
I see that the edges shared by two triangles are not duplicated. To check for this case I sorted the nodes and the edges. Let me know if it is ok:
CF = [ 1 2 3; 2 3 4];
% sorted nodes (always increasing node)
CFs = sort(CF,2);
% remove repetitions and get edges
CE = unique(reshape(CF(:,[1 2 2 3 1 3]).',2,3*size(CF,1)).','rows')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by