You have to assign the output of bitset to something.
I would suggest, by the way, that you consider bitand
img(i,j) = bitand(img(i,j), uint8(240));
You can do the whole thing without a loop:
newimg = bitand(img, uint8(240));
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!