马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
本帖最后由 mzbys 于 2016-6-6 15:34 编辑
A=[1 2;3 4;5 6];
%csvd
[u,s,v]=csvd(A);
for i=1:2
B=v*u'/s(i);
end
如何求i=1和2时 两个B之和?
其中CSVD函数如下:
function [U,s,V] = csvd(A,tst)
%CSVD Compact singular value decomposition.
%
% s = csvd(A)
% [U,s,V] = csvd(A)
% [U,s,V] = csvd(A,'full')
%
% Computes the compact form of the SVD of A:
% A = U*diag(s)*V',
% where
% U is m-by-min(m,n)
% s is min(m,n)-by-1
% V is n-by-min(m,n).
%
% If a second argument is present, the full U and V are returned.
% Per Christian Hansen, IMM, 06/22/93.
if (nargin==1)
if (nargout > 1)
[m,n] = size(A);
if (m >= n)
[U,s,V] = svd(full(A),0); s = diag(s);
else
[V,s,U] = svd(full(A)',0); s = diag(s);
end
else
U = svd(full(A));
end
else
if (nargout > 1)
[U,s,V] = svd(full(A)); s = diag(s);
else
U = svd(full(A));
end
end
|