addmrows.m

来自「Matlab package for PCA for datasets with」· M 代码 · 共 52 行

M
52
字号
%  ADDMROWS - Add unobserved rows to PCA solution%%  [ A_new, Av_new ] = ADDMROWS( A, Av, Ir, n1x, Va ) adds the columns%  removed by RMEMPTY to the found parameter A.%%  Va is the variance of the prior for A. Va=NaN corresponds to%  no prior for A.%%  See also RMEMPTY, ADDMCOLS%  This software is provided "as is", without warranty of any kind.%  Alexander Ilin, Tapani Raikofunction [ A_new, Av_new ] = addmrows( A, Av, Ir, n1x, Va );ncomp = size(A,2);% Might not be very efficientIr2 = setdiff( 1:n1x, Ir );if isnan(Va)    A_new = repmat( NaN, n1x, ncomp );else    A_new = zeros(n1x, ncomp);endA_new(Ir,:) = A;if nargout >= 2 & ~isempty(Av)    if iscell(Av)        Av_new = cell(1,n1x);        cur = 1;        for i = 1:length(Ir)            Av_new{Ir(i)} = Av{i};        end        for i = 1:length(Ir2)            Av_new{Ir2(i)} = diag(Va);        end    else        % Av is a matrix, each column contains the diagonal        % elements of the covariance matrix of the corresponding        % column of A                % Va must be a row vector, each element is a prior for        % the corresponding column of A                Av_new = repmat( Va, n1x, 1 );        Av_new(Ir,:) = Av;    endelse    Av_new = [];end

⌨️ 快捷键说明

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