This is basically logical indexing. deg>1 returns a logical matrix of size deg with value 1 at coordinates where deg>1 condition is satisfied. This logical matrix then can be used for logical indexing. You refer the following blog for more details.
https://blogs.mathworks.com/loren/2013/02/20/logical-indexing-multiple-conditions/