Info

此问题已关闭。 请重新打开它进行编辑或回答。

I'm following the code below from that code they got a figure with three data, but mine when I plot I got two is there anything wrong I followed the step I'm suppose to get three as well

1 次查看(过去 30 天)
this the example I'm following
n1a=100;
n1b=100;
n2=100;
X1a=[randn(2,n1a).*repmat([1;2],[1 n1a])+repmat([-6;0],[1 n1a])];
X1b=[randn(2,n1b).*repmat([1;2],[1 n1b])+repmat([ 6;0],[1 n1b])];
X2= [randn(2,n2 ).*repmat([1;2],[1 n2 ])+repmat([ 0;0],[1 n2 ])];
X=[X1a X1b X2];
Y=[ones(n1a+n1b,1);2*ones(n2,1)];
%%%%%%%%%%%%%%%%%%%%%% Computing LFDA solution
[T,Z]=LFDA(X,Y,1);
%%%%%%%%%%%%%%%%%%%%%% Displaying original 2D data
figure(1)
clf
hold on
h=plot([-T(1) T(1)]*100,[-T(2) T(2)]*100,'k-','LineWidth',2);
legend('LFDA subspace',1)
h=plot(X(1,Y==1),X(2,Y==1),'bo');
h=plot(X(1,Y==2),X(2,Y==2),'rx');
axis equal
axis([-10 10 -10 10])
title('Original 2D data and subspace found by LFDA')
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 12 12]);
print -depsc original_data
%%%%%%%%%%%%%%%%%%%%%% Displaying projected data
figure(2)
clf
subplot(2,1,1)
hold on
hist(Z(Y==1),linspace(min(Z),max(Z),20));
h=get(gca,'Children');
set(h,'FaceColor','b')
axis([min(Z) max(Z) 0 inf])
title('Data projected onto 1D LFDA subspace')
subplot(2,1,2)
hold on
hist(Z(Y==2),linspace(min(Z),max(Z),20));
h=get(gca,'Children');
set(h,'FaceColor','r')
axis([min(Z) max(Z) 0 inf])
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 12 12]);
print -depsc projected_data
THIS IS THE CODE i USE MY data
and
n1a=961;
n1b=961;
n2=961;
load Normal
load fault1
load fault3
Normal = zscore(Normal);
fault1 = zscore(fault1);
fault3 = zscore(fault3);
X=[Normal; fault1; fault3];
X=X';
Y=[ones(n1a,1);2*ones(n1b,1);3*ones(n1b,1)];
% Y=Y';
%%%%%%%%%%%%%%%%%%%%%% Computing LFDA solution
[T,Z]=LFDA(X,Y,1);
%%%%%%%%%%%%%%%%%%%%%% Displaying original 2D data
figure(1)
clf
hold on
set(gca,'FontName','Helvetica')
set(gca,'FontSize',12)
h=plot([-T(1) T(1)]*100,[-T(2) T(2)]*100,'k-','LineWidth',2);
legend('LFDA subspace',1)
h=plot(X(1,Y==1),X(2,Y==1),'bo');
h=plot(X(1,Y==2),X(2,Y==2),'rx');
axis equal
axis([-10 10 -10 10])
title('Original 2D data and subspace found by LFDA')
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 12 12]);
print -depsc original_data
%%%%%%%%%%%%%%%%%%%%%% Displaying projected data
figure(2)
clf
subplot(2,1,1)
hold on
set(gca,'FontName','Helvetica')
set(gca,'FontSize',12)
hist(Z(Y==1),linspace(min(Z),max(Z),20));
h=get(gca,'Children');
set(h,'FaceColor','b')
axis([min(Z) max(Z) 0 inf])
title('Data projected onto 1D LFDA subspace')
subplot(2,1,2)
hold on
set(gca,'FontName','Helvetica')
set(gca,'FontSize',12)
hist(Z(Y==2),linspace(min(Z),max(Z),20));
h=get(gca,'Children');
set(h,'FaceColor','r')
axis([min(Z) max(Z) 0 inf])
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 12 12]);
print -depsc projected_data_LFDA

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by