B = sqrt(X)
B = sqrt( returns
the square root of each element of the array
For the elements of
X that are negative or complex,
sqrt function's domain includes
negative and complex numbers, which can lead to unexpected results
if used unintentionally. For negative and complex numbers
= u + i*w, the complex square root
sqrt(r)*(cos(phi/2) + 1i*sin(phi/2))
r = abs(z) is the radius and
= angle(z) is the phase angle on the closed interval
<= phi <= pi.
If you want negative and complex numbers to return error messages
rather than return complex results, use
Create a row vector containing both negative and positive values.
X = -2:2
X = -2 -1 0 1 2
Compute the square root of each element of
Y = sqrt(X)
Y = 0.0000 + 1.4142i 0.0000 + 1.0000i 0.0000 + 0.0000i 1.0000 + 0.0000i 1.4142 + 0.0000i
X— Input array
Input array, specified as a numeric scalar, vector, matrix, or multidimensional array.
Complex Number Support: Yes
sqrtm for the matrix
This function fully supports tall arrays. For more information, see Tall Arrays.
Usage notes and limitations:
Simulation produces an error. Generated standalone
NaN when the input value
real, but the output should be complex. To get the complex result,
make the input value complex by passing in