Count occurances on multidimensional matrix with multiple criteia on different dimnesions
1 次查看(过去 30 天)
显示 更早的评论
I would like to count occurances of >= 90 on page 1 and = 2 on page 2 of a multidimensional matrix where both criteria in the same location need to be met to be true for the following:
A(:,:,1)=
[90 95 90 80
70 90 95 70
60 90 90 60]
A(:,:,2)=
[1 1 1
2 2 2
1 2 1]
The answer for the above example should be 3.
Thank you in advance for any assistance.
回答(2 个)
Davide Masiello
2022-10-5
A(:,:,1) = [ 90 95 90 80;...
70 90 95 70;...
60 90 90 60;...
];
A(:,:,2) = [ 1 1 1 1;...
2 2 2 2;...
1 2 1 1;...
];
B = (A(:,:,1) >= 90) + (A(:,:,2) == 2)
N = sum(B==2,'all')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!