how to select specific values of nx3 array where the third dimension contains values in range of 1 to 11 of the 3rd dimension?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, i was having a struct contains 2 fields of faces and vertices, now i need to extract the vertices from the struct where the z axis in the range of 1:11 then delete the faces that not related to them however, i tried to convert the struct into cell array, then i split the vertices in separate nx3 array to work on it. now what is the expression i need to complete with in order to extract only values from 1 to 11 of the 3rd dimension from this nx3 array? this is my trials :
C2 = struct2cell(splitpatch2);
f2=C2{1,1};
v2=C2{2,1};
Ver2=v2(:,:,1:11)
the last line gives me a "Index exceeds matrix dimensions." error.
0 commentaires
Réponse acceptée
KSSV
le 3 Oct 2018
Modifié(e) : KSSV
le 4 Oct 2018
S = load('splitpatch2.mat') ;
f = S.splitpatch2.faces ;
v = S.splitpatch2.vertices ;
nnode = length(v) ;
idx = v(:,3)>=1 & v(:,3)<=11 ;
iwant_nodes = find(idx) ;
iwant = v(idx,:) ;
% Plot extracted mesh alone
v_iwant = NaN(nnode,3) ;
v_iwant(idx,:) = v(idx,:) ;
trisurf(f,v_iwant(:,1),v_iwant(:,2),v_iwant(:,3)) ;
% Get faces which has iwant
idx1 = find(ismember(f(:,1),iwant_nodes)) ;
idx2 = find(ismember(f(:,2),iwant_nodes)) ;
idx3 = find(ismember(f(:,3),iwant_nodes)) ;
idx123 = [idx1 ; idx2 ; idx3] ;
iwant_faces = f(unique(idx123),:) ;
4 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graph and Network Algorithms 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!