MATLAB: Pulling subset from a 2D matrix

MATLABmatrixsubset

Hi,
I am struggling how to extract part of a 2D matrix based on logical criteria:
example:
a=[1 1 1 ; 2 2 2 ; 3 3 3]
b=a<3 % let say I want to have the subset where a<3
mySubset=a.*b
how can I obtain the subset using logic and not having a line of zeros where a=3?
Thanks

Best Answer

a=[1 1 1 ; 2 2 2 ; 3 3 3]
b==a<3
mySubset=a.*b