MATLAB: Subtracting multiple matrices from the same matrix

MATLABmatrices

I have a 3D matrix (35,43,144) and a 2D matrix (35,43)
I need to produce 144 new 35×43 matrices by subtracting the 2D matrix from each of the 144 matrices in the 3D matrix. I am unsure how to do this as the matrices do not have consistent dimensions.
Thank you in advance for any help

Best Answer

bsxfun(@minus, The3DMatrix, The2DMatrix)
Related Question