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 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
KSSV
il 3 Ott 2018
Modificato: KSSV
il 4 Ott 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Graph and Network Algorithms in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!