kpca_plot.m

来自「KPCA是一种非线性的盲源分离方法」· M 代码 · 共 45 行

M
45
字号
function kpca_plot(basis,gr,ip);
%KPCA_PLOT visualizes the kpca basis.
%
%   usage
%      kpca_plot(basis);
%
%   input
%      basis    kpca basis generated by kpca_calc (see there)
%      gr       resolution (default == 17)
%      ip       if ip==1 then the input vectors are plotted as well
%               (default ip==1)
%
%   see also
%      kpca_calc, kpca_map
%
%   STH * 12MAR2002

if ~exist('gr')|isempty(gr), gr = 17; end
if ~exist('ip')|isempty(ip), ip = 1; end

if size(basis.xs,1)~=2
  error([mfilename ': can only visualize two dim input spaces.'])
end

% plot resulting directions
x1min = min(basis.xs(1,:));  x1max = max(basis.xs(1,:));
x2min = min(basis.xs(2,:));  x2max = max(basis.xs(2,:));
[X,Y] = meshgrid(linspace(x1min,x1max,gr),linspace(x2min,x2max,gr));
Z = [X(:) , Y(:)]';
phiZ = kpca_map(Z,basis);
clf
d = size(basis.V,2);
for i = 1:d
  supplot(d,i)
  pcolor(X,Y,reshape(phiZ(i,:),[gr gr]))
  hold on
  contour(X,Y,reshape(phiZ(i,:),[gr gr]),10)
  shading flat
  if ip==1
    plot(basis.xs(1,:),basis.xs(2,:),'.','markersize',1)
  end
  title(['\lambda_{' num2str(i) '}=' num2str(basis.Lambda(i,i))])
  axis equal, axis tight, axis off
end

⌨️ 快捷键说明

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