MATLAB: Remove values from matrix based on another matrix

logical indexingremove rows

Hi,
I have matrix A with the dimensions of 45 x 73 x 28. I have matrix B with the dimensions of m x n x p. I would like to remove all the rows in B that contain any values exceeding the corresponding values in A? This means rows to be deleted from B would have m>45 and/or n>73 and/or p>28. Basically A would be the limit for B.
I'm sure this is a common problem and someone must have asked before but I was not able to find the asnwer. Could someone please help?

Best Answer

B=B(1:45,1:73,1:28)