📄 lledemo.asv
字号:
function lledemo;
N=2000;
K=12;
d=2;
clf; colordef none; colormap jet; set(gcf,'Position',[200,400,620,200]);
% PLOT TRUE MANIFOLD
tt0 = (3*pi/2)*(1+2*[0:0.02:1]); hh = [0:0.125:1]*30;
xx = (tt0.*cos(tt0))'*ones(size(hh));
yy = ones(size(tt0))'*hh;
zz = (tt0.*sin(tt0))'*ones(size(hh));
cc = tt0'*ones(size(hh));
subplot(1,3,1); cla;
surf(xx,yy,zz,cc);
view([12 20]); grid off; axis off; hold on;
lnx=-5*[3,3,3;3,-4,3]; lny=[0,0,0;32,0,0]; lnz=-5*[3,3,3;3,3,-3];
lnh=line(lnx,lny,lnz);
set(lnh,'Color',[1,1,1],'LineWidth',2,'LineStyle','-','Clipping','off');
axis([-15,20,0,32,-15,15]);
% GENERATE SAMPLED DATA
tt = (3*pi/2)*(1+2*rand(1,N)); height = 21*rand(1,N);
X = [tt.*cos(tt); height; tt.*sin(tt)];
% SCATTERPLOT OF SAMPLED DATA
subplot(1,3,2); cla;
scatter3(X(1,:),X(2,:),X(3,:),12,tt,'+');
view([12 20]); grid off; axis off; hold on;
lnh=line(lnx,lny,lnz);
tt=linspace(0,4*pi,100);
X=[tt.*sin(tt);tt.*cos(tt)];
%X=X-repmat(mean(X,2),1,length(X));
figure;
try
Dis=distance(X);
catch
error('ERROR! Are you sure distance.m is in the path?');
end;
subplot(2,1,1);
scatter(X(1,:),X(2,:),60,tt,'filled'); axis equal;
title('Original');
drawnow;
% RUN LLE ALGORITHM
Y=lle(X,K,d);
subplot(2,1,2);
scatter(Y(1,:),Y(2,:),60,tt,'filled'); axis equal;
title('Reduced Dimensionality');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -