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

1 vue (au cours des 30 derniers jours)
kiet tran
kiet tran le 9 Nov 2019
Commenté : kiet tran le 15 Nov 2019
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 commentaire
Walter Roberson
Walter Roberson le 9 Nov 2019
I cannot tell what your rule is for constructing the edges?

Connectez-vous pour commenter.

Réponse acceptée

Fabio Freschi
Fabio Freschi le 9 Nov 2019
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')

Plus de réponses (0)

Catégories

En savoir plus sur Geometric Transformation and Image Registration dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by