Main Content
power, .^
Symbolic array power
Syntax
Description
Examples
Square Each Matrix Element
Create a 2
-by-3
matrix.
A = sym('a', [2 3])
A = [ a1_1, a1_2, a1_3] [ a2_1, a2_2, a2_3]
Square each element of the matrix.
A.^2
ans = [ a1_1^2, a1_2^2, a1_3^2] [ a2_1^2, a2_2^2, a2_3^2]
Use Matrices for Base and Exponent
Create a 3
-by-3
symbolic Hilbert matrix and a 3
-by-3
diagonal matrix.
H = sym(hilb(3)) d = diag(sym([1 2 3]))
H = [ 1, 1/2, 1/3] [ 1/2, 1/3, 1/4] [ 1/3, 1/4, 1/5] d = [ 1, 0, 0] [ 0, 2, 0] [ 0, 0, 3]
Raise the elements of the Hilbert matrix to the powers of the diagonal matrix. The base and the exponent must be matrices of the same size.
H.^d
ans = [ 1, 1, 1] [ 1, 1/9, 1] [ 1, 1, 1/125]