MATLAB Compiler | ![]() ![]() |
Array power function for real-only output.
Syntax
Z = realpow(X,Y)
Description
realpow
returns X
raised to the Y
power. realpow
operates element-wise on matrices. The range of realpow
is the set of all real numbers. In other words, if X
raised to the Y
power yields a complex answer, then realpow
does not return an answer. Instead, realpow
signals an error.
If X
is negative and Y
is not an integer, the resulting power is complex and realpow
signals an error.
realpow
is similar to the array power operator (.^
) of MATLAB. However, the range of .^
is much broader than the range of realpow
. (The range of .^
includes all real and all imaginary numbers.) If X
raised to the Y
power yields a complex answer, then you must use .^
instead of realpow
. However, if X
raised to the Y
power yields a real answer, then you should use realpow
for two reasons.
First, subsequent access of Z
may execute more efficiently if Z
is calculated with realpow
rather than .^
. Using realpow
forces the MATLAB Compiler to impute that Z
, X
, and Y
are real. Using .^
typically forces the MATLAB Compiler to impute the complex type to Z
.
Second, the compiled version of realpow
may run somewhat faster than the compiled version of .^
. (However, the interpreted version of realpow
may run somewhat slower than the interpreted version of .^
.)
See Also
exp
, log
, log2
, logm
, log10
, reallog
, realsqrt
![]() | reallog | realsqrt | ![]() |