Singular value decomposition of symbolic matrix
[
returns numeric unitary matricesU
,S
,V
] = svd(A
)U
和V
含有奇异矢量的列和对角线矩阵S
containing the singular values. The matrices satisfy the conditionA = U*S*V'
, whereV'
is the Hermitian transpose (the complex conjugate transpose) ofV
。奇异矢量计算使用可变精度算术。svd
不计算符号奇异向量。因此,输入矩阵A
must be convertible to floating-point numbers. For example, it can be a matrix of symbolic numbers.
Compute the singular values of the symbolic5
-通过-5
magic square:
a = sym(魔术(5));sigma = svd(a)
Sigma = 65 5 ^(1/2)*(1345 ^(1/2)+ 65)^(1/2)65 ^(1/2)*(5 ^(1/2)+ 5)^(1/ 2)65 ^(1/2)*(5 - 5 ^(1/2))^(1/2)5 ^(1/2)*(65 - 1345 ^(1/2))^(1/ 2)
现在,计算元素是符号表达式的矩阵的奇异值:
syms t真实a = [0 1;-1 0];E = EXPM(t * a)sigma = svd(e)
e = [cos(t),sin(t)] [-sin(t),cos(t)] sigma =(cos(t)^ 2 + sin(t)^ 2)^(1/2)(cos(t)^ 2 + sin(t)^ 2)^(1/2)
简化结果:
sigma = simplify(sigma)
sigma = 1 1
For further computations, remove the assumption ont
通过重新创建它使用syms
:
syms t
转换符号的元素5
-通过-5
幻灯片到浮点数,并计算矩阵的奇异值:
a = sym(魔术(5));Sigma = SVD(VPA(A))
差= 65.0 22.547088685879657984674226396467 21.687425355202639411956035427154 13.403565997991492328585154445703 11.900789544861194527298509087321
Compute the singular values and singular vectors of the5
-通过-5
magic square:
old = digits(10); A = sym(magic(5)) [U, S, V] = svd(A) digits(old)
A = [ 17, 24, 1, 8, 15] [ 23, 5, 7, 14, 16] [ 4, 6, 13, 20, 22] [ 10, 12, 19, 21, 3] [ 11, 18, 25, 2, 9] U = [ 0.4472135955, 0.5456348731, 0.5116672736, -0.1954395076, -0.4497583632] [ 0.4472135955, 0.4497583632, -0.1954395076, 0.5116672736, 0.5456348731] [ 0.4472135955, 2.420694008e-15, -0.632455532, -0.632455532, 1.29906993e-15] [ 0.4472135955, -0.4497583632, -0.1954395076, 0.5116672736, -0.5456348731] [ 0.4472135955, -0.5456348731, 0.5116672736, -0.1954395076, 0.4497583632] S = [ 65.0, 0, 0, 0, 0] [ 0, 22.54708869, 0, 0, 0] [ 0, 0, 21.68742536, 0, 0] [ 0, 0, 0, 13.403566, 0] [ 0, 0, 0, 0, 11.90078954] V = [ 0.4472135955, 0.4045164361, 0.2465648962, 0.6627260007, 0.3692782866] [ 0.4472135955, 0.005566159714, 0.6627260007, -0.2465648962, -0.5476942741] [ 0.4472135955, -0.8201651916, -3.091014288e-15, 6.350407543e-16, 0.3568319751] [ 0.4472135955, 0.005566159714, -0.6627260007, 0.2465648962, -0.5476942741] [ 0.4472135955, 0.4045164361, -0.2465648962, -0.6627260007, 0.3692782866]
计算产品U
,S
, and the Hermitian transpose ofV
具有10位准确度。结果是原始矩阵A
with all its elements converted to floating-point numbers:
vpa(U*S*V',10)
ANS = [17.0,24.0,1.0,8.0,15.0] [23.0,5.0,70,14.0,16.0] [4.0,6.0,13.0,20.0,22.0] [10.0,12.0] [10.0,12.0,19.0,21.0,3.0] [11.0,18.0,25.0,2.0,9.0]
Use the second input argument0
to compute the thin, or economy, SVD of this3
-通过-2
matrix:
old = digits(10); A = sym([1 1;2 2; 2 2]); [U, S, V] = svd(A, 0)
u = [0.33333333,-0.66666667] [0.6666666667]] [0.666666666],0.6666666667,0.6666666667,0.666666667,0.6666666667,0.666666667,0.666666667,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0。
现在,使用第二个输入参数“econ”
计算薄或经济的矩阵B
。Here, the3
-通过-2
matrixB
是颠倒的A
。
B = A'; [U, S, V] = svd(B, 'econ') digits(old)
U = [ 0.7071067812, -0.7071067812] [ 0.7071067812, 0.7071067812] S = [ 4.242640687, 0] [ 0, 0] V = [ 0.3333333333, 0.6666666667] [ 0.6666666667, -0.6666666667] [ 0.6666666667, 0.3333333333]
The second arguments0
和“econ”
仅影响返回的矩阵的形状。这些参数不会影响计算的性能。
打电话svd
for numeric matrices that are not symbolic objects invokes the MATLAB®svd
function.
涉及许多符号变量的矩阵计算可能很慢。为了提高计算速度,通过代替一些变量来减少符号变量的数量。