Element-wise Power: .^

If A and B are two matrices of the same size, or either one is a scalar, then A .^ B is A raised to power of B element-wise.

For example, if want to square each entry of a vector

>> A = [1, 2, 3, 4, 5];
>> A .^ 2
    [1, 4, 9, 16, 25]
>> B = [-2, -1, 0, 1, 2];
>> A .^ B
    1         0.5       1         4         25



oz 2009-12-22