MATLAB: Make the FIND more compact

compact line

Hi Coder, Just out of curiosity, if we can make the last two lines into a single line?
M = zeros (9,1);
Alert_LessThree = 1:3;
B = [2 4 4 4 1 5 6 7 8];
[tf,Ioc_Alert_LessThree] = find (ismember(B, Alert_LessThree));
M(Ioc_Alert_LessThree,:) = 2;
Thank you

Best Answer

M( ismember(B, Alert_LessThree) ) = 2
Related Question