function x = realsqrt(x) %REALSQRT sqrt which raises an error if complex numbers result. % % This is for older versions of Octave, which didn't ship with this function. x = sqrt(x); if any(imag(x(:))) error('realsqrt caught a complex result'); end