extracting information from structer under specific conditions
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Abdelwahab Fawzy
am 16 Jul. 2016
Beantwortet: Azzi Abdelmalek
am 16 Jul. 2016
if there is a structure for 100 nodes. the three fields of the structure are (xd , yd and ID) where,,
xd--> X-dimension , yd--> Y_dimension , ID ==> node's order or its ID
and i have a matrix DIM(5,2) which contains the dimensions of 5 nodes where , DIM(:,1) --> refer to xd , DIM(:,2) --> refer to yd
now i want to know the ID of these 5 nodes
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 16 Jul. 2016
%--------Example-----------------------------------------------------------
A=struct('xd',num2cell(randi(100,100,1)),'yd',num2cell(randi(100,100,1)),'ID',num2cell(rand(100,1)))
b=[[A.xd]' [A.yd]']
M=b(randperm(100,5),:)
%------The code-------------------------------------
N=cell2mat(struct2cell(A)')
idx=ismember(N(:,1:2),M,'rows')
ID=N(idx,3)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!