I have a 2400x2400 matrix that I would like to use as a mask for each layer of a 2400x2400x46 matrix. Since the matrix dimensions are not equal, I cannot do so by simply multiplying the mask matrix by the larger matrix. How might I do this?

1 view (last 30 days)
I have a 2400x2400 matrix that I would like to use as a mask for each layer of a 2400x2400x46 matrix. Since the matrix dimensions are not equal, I cannot do so by simply multiplying the mask matrix by the larger matrix. How might I do this? The end goal is to have a 2400x2400x46 matrix that has "NaN" for all "NaN" values in the mask matrix.
Thank you.

Accepted Answer

Image Analyst
Image Analyst on 29 Nov 2012
% Mask the image.
maskedHyperSpectralImage = bsxfun(@times, HyperSpectralImage, cast(mask,class(HyperSpectralImage)));
Note: the above is all one line of code.

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!