# realpow

Array power for real-only output

## Syntax

```Z = realpow(X,Y) ```

## Description

`Z = realpow(X,Y)` raises each element of array `X` to the power of its corresponding element in array `Y`. Arrays `X` and `Y` must be the same size or be compatible. The range of `realpow` is the set of all real numbers, i.e., all elements of the output array `Z` must be real.

If either `X` or `Y` is a table or timetable, then `Z` is a table or timetable. (since R2023a)

## Examples

collapse all

Create a 3-by-3 matrix with the same value in each element.

`X = -2*ones(3,3)`
```X = 3×3 -2 -2 -2 -2 -2 -2 -2 -2 -2 ```

Compute a 3-by-3 matrix of integer values.

`Y = pascal(3)`
```Y = 3×3 1 1 1 1 2 3 1 3 6 ```

Compute the element-wise powers of the elements in `X` corresponding to the exponents defined in `Y`.

`Z = realpow(X,Y)`
```Z = 3×3 -2 -2 -2 -2 4 -8 -2 -8 64 ```

## Input Arguments

collapse all

Operands, specified as scalars, vectors, matrices, multidimensional arrays, tables, or timetables. `X` and `Y` must either be the same size or have sizes that are compatible (for example, `X` is an `M`-by-`N` matrix and `Y` is a scalar or `1`-by-`N` row vector). For more information, see Compatible Array Sizes for Basic Operations.

The values in `X` and `Y` must be real. If `X` and `Y` are of integer data types, then the values of `Y` must also be nonnegative integers.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical` | `char` | `table` | `timetable`

## Version History

Introduced before R2006a

expand all