how to select specific values of nx3 array where the third dimension contains values in range of 1 to 11 of the 3rd dimension?

3 ビュー (過去 30 日間)
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.

採用された回答

KSSV
KSSV 2018 年 10 月 3 日
編集済み: KSSV 2018 年 10 月 4 日
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 件のコメント
sana3 sal
sana3 sal 2018 年 10 月 4 日
This is awesome thanks alot ♥

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by