pcadata.m

来自「image separation using neural net」· M 代码 · 共 60 行

M
60
字号
function [A, S, M] = pcadata(type, varargin)
% PCADATA   Get data for PCA
%
% [A S M] = pcadata(type)
%   where type is one of
% '2d'          two dimensional data
% '3d'          three dimensional data
% '2dbad'       two dimensional, badly scaled data
% 'seperated'   data with highly seperated eigenvalues
% 'close'       data with close eigenvalues (from Kung and Diamantaras)
%
% A is the rotated data
% S is the orignal source data
% M is the mixing/rotating matrix


%
% David Gleich
% CS 152 - Neural Networks
% 12 December 2003
%
if (strcmpi(type, '2d'))
    M = rand(2);
    M = orth(M);
    S = diag([1 .25])*randn(2,250);
    A = M*S;
elseif (strcmpi(type, '3d'))
    M = rand(3);
    M = orth(M);
    S = diag([1.5 .75 .1])*randn(3,500);
    A = M*S;
elseif (strcmpi(type, '2dbad'))
    M = [1 .02; .01 1];
    S = randn(2,250);
    A = M*S;
elseif (strcmpi(type, 'separated'))
    M = rand(16,16);
	M = orth(M);
	
	Spowers = rand(16,1)*10;
	Spowers = sort(Spowers);
	
	S = zeros(16,5000);
	for (ii = 1:16)
        S(ii, :) = randn(1,5000);
        S(ii, :) = 2^(3-ii)*(S(ii,:) - mean(S(ii, :)));
	end;
	
	A = M*S;

elseif (strcmpi(type, 'close'))
    S = 2*(rand(16,512) - 0.5);
    A = S;
    A(2:end,:) = A(2:end,:) + A(1:end-1, :)/2;
end;




⌨️ 快捷键说明

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