Example: Finding Minima and Maxima of an Array
1. Define a vector where one of its elements is a complex number.
2. Use the
IsScalar function to check if the second element of the vector is a scalar.
Complex numbers are considered scalars.
| You can use the IsArray function to check if a variable is an array. |
3. Use the
min function to find the smallest element in the vector.
The min function returns the smallest real number plus the smallest imaginary part. In this case, it returned -2 and an imaginary part of 0.
4. Use
max to find the largest element in the vector.
The max built-in function returns the largest real number plus the largest imaginary part.