声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1920|回复: 5

[编程技巧] matlab 若干矩阵矩阵求和?

[复制链接]
发表于 2016-6-6 15:15 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

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


本帖被以下淘专辑推荐:

回复
分享到:

使用道具 举报

发表于 2016-6-6 15:35 | 显示全部楼层
这是干嘛的呢
发表于 2016-6-6 15:57 | 显示全部楼层
你的子程序运行不了,而且不知道你这个程序得到的B到底是什么样子的?就木有办法了!!!

点评

确实运行不了  详情 回复 发表于 2016-6-6 16:01
发表于 2016-6-6 16:01 | 显示全部楼层
ZH----过客 发表于 2016-6-6 15:57
你的子程序运行不了,而且不知道你这个程序得到的B到底是什么样子的?就木有办法了!!!

确实运行不了

点评

将下面那个函数添加到路径下面  详情 回复 发表于 2016-6-6 16:11
 楼主| 发表于 2016-6-6 16:11 | 显示全部楼层

将下面那个函数添加到路径下面

点评

搜噶 我试试 谢谢  详情 回复 发表于 2016-6-7 10:54
发表于 2016-6-7 10:54 | 显示全部楼层
mzbys 发表于 2016-6-6 16:11
将下面那个函数添加到路径下面

搜噶  我试试  谢谢
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-4 05:00 , Processed in 0.080413 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表