using FIND in 3D matrix
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to find the 3rd dimension index value for the following case
A(:,:,1)=[1 2 ; 3 4]
A(:,:,2)=[9 8 ; 4 4]
A(:,:,3)=[2 4 ; 7 4]
B=[1 2 ; 3 4]
How can I use find(.) for this purpose
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 29 Mai 2013
idx=find(arrayfun(@(x) isequal(A(:,:,x),B),1:size(A,3)))
0 Kommentare
Weitere Antworten (2)
Sean de Wolski
am 29 Mai 2013
I would do that like this:
A(:,:,1)=[1 2 ; 3 4];
A(:,:,2)=[9 8 ; 4 4];
A(:,:,3)=[2 4 ; 7 4];
A(:,:,4)=A(:,:,1);
B=[1 2 ; 3 4];
idx = find(all(all(bsxfun(@eq,A,B),1),2))
Find where all elements in rows/cols are equal in pages
2 Kommentare
Andrei Bobrov
am 29 Mai 2013
[ii,jj]=ismember(reshape(A,[],size(A,3))',B(:)','rows');
out = jj(ii);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices 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!