主要内容

svd

Singular value decomposition of symbolic matrix

描述

example

sigma= SVD(A)returns a vectorsigmacontaining the singular values of a symbolic matrixA

example

[U,S,V] = svd(A)returns numeric unitary matricesUV含有奇异矢量的列和对角线矩阵Scontaining the singular values. The matrices satisfy the conditionA = U*S*V', whereV'is the Hermitian transpose (the complex conjugate transpose) ofV。奇异矢量计算使用可变精度算术。svd不计算符号奇异向量。因此,输入矩阵Amust be convertible to floating-point numbers. For example, it can be a matrix of symbolic numbers.

example

[U,S,V] = svd(A,0)returns the thin, or economy, SVD. IfAis anm-通过-nmatrix withm > n, thensvdcomputes only the firstncolumns ofU。在这种情况下,Sis ann-通过-nmatrix. Form <= n, this syntax is equivalent tosvd(A)

example

[U,S,V] = svd(A,'econ')also returns the thin, or economy, SVD. IfAis anm-通过-nmatrix withm> = n,然后这个语法相当于svd(A,0)。ForM ,svdcomputes only the firstmcolumns ofV。在这种情况下,Sis anm-通过-mmatrix.

例子

Symbolic Singular Values

Compute the singular values of the symbolic5-通过-5magic 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

Floating-Point Singular Values

转换符号的元素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-通过-5magic 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位准确度。结果是原始矩阵Awith 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]

薄或经济SVD

Use the second input argument0to compute the thin, or economy, SVD of this3-通过-2matrix:

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-通过-2matrixB是颠倒的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]

Input Arguments

全部收缩

输入矩阵指定为符号矩阵。对于具有一个输出参数的语法,元素Acan be symbolic numbers, variables, expressions, or functions. For syntaxes with three output arguments, the elements ofAmust be convertible to floating-point numbers.

Output Arguments

全部收缩

Singular values of a matrix, returned as a vector. Ifsigma是数字矢量,然后其元素按降序排序。

Singular vectors, returned as a unitary matrix. Each column of this matrix is a singular vector.

奇异值,作为对角线矩阵返回。该矩阵的对角线元素以降序显示。

Singular vectors, returned as a unitary matrix. Each column of this matrix is a singular vector.

提示

  • The second arguments0“econ”仅影响返回的矩阵的形状。这些参数不会影响计算的性能。

  • 打电话svdfor numeric matrices that are not symbolic objects invokes the MATLAB®svdfunction.

  • 涉及许多符号变量的矩阵计算可能很慢。为了提高计算速度,通过代替一些变量来减少符号变量的数量。

在R2006A之前介绍