⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 randpds.m

📁 该工具箱是用于统计模式识别的
💻 M
字号:
function [C]=randpds(dim,diagm)% [C]=randpds(dim,diagm)%% RANDPDS generates random positive definite symetric matrix of%   given dimension.%% Input:%  dim [1x1] given dimension of desired matrix.%  diagm [1x1] if diagm==1 then then diagonal matrix is generated.%% Output:%  C [dim x dim] positive definite symetric matrix.%% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz% Written Vojtech Franc (diploma thesis)% Modifications% 26-feb-2001 V.Francif nargin < 2,  diagm=0;endif diagm==0,    %%%%%%%%%%%%%  % creates randomly lowwer triangual matrix T with non-zero   % members on diagonal  T=rand(dim)*2-1+diag(rand(dim,1)*10-1);  for j=1:dim-1,    for i=j+1:dim,      T(j,i)=0;    end  end  % ensures that any diagonal member woun't be zero  for i=1:dim,    while T(i,i)==0,      T(i,i)=rand(1)*2-1;    end  end  %%%%%%%%%%  % makes orthonormal R  R=orth(T);  %%%%%%%%%%%%%%  % creates diag. matrix with positive members on diagonal  D=diag(rand(1,dim));  %%%%%%%%%%%%%%%%%5  % creates Random Positive Definite Symetric Matrix  C=R'*D*R;  %%%%  % the following line is due to numerical troubles  if rank(C)~=dim, C=randpds(dim); end  else  %%%%  C=diag(rand(dim,1));endreturn

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -