To perform element-wise power operation in Matlab, we use the power operator .^
. Here's how to use it to perform the operation out = x.^y
:
main.m42 chars4 lines
This raises each element of the x
array to the corresponding power in the y
array, and returns an array of the same size as x
and y
. The resulting out
array would be:
main.m25 chars3 lines
If x
and y
were matrices of the same size, then the power operation would be performed element-wise as well.
gistlibby LogSnag