3D matrix pattern matching
4 ビュー (過去 30 日間)
古いコメントを表示
Find which row of 3d matrix matches an array along the third dimension. For ex:![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/623298/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/623298/image.png)
I want to find [1 0 0] along 3rd dimension of Zb, so here Zb(4,1,:) , Zb(5,4,:) and some others match [1, 0, 0]. How to know if the match occurs (for any random value of 3rd dimension of matrix) and if so, what are the row, column indices? Also, can this be done without for loop?
0 件のコメント
採用された回答
Jonas
2021 年 5 月 19 日
you can use e.g.
a(:,:,1)=ones(2);
a(:,:,2)=2*ones(2);
a(:,:,3)=[1 3; 3 1];
pattern(1,1,:)=1:3;
whereToFind=all(a==pattern,3)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!