If you need to do it in one line, this will work:
Or, you could do the test in advance, saving some CPU cycles.
So, why did your original idea not work? Because sqrt(A) has numel(A) elements in the result. However, A(A>0) does not have that many elements. So MATLAB tries to fit a square peg into a round hole, and then gives up. Unless you do as I suggested.