0001 0002 clear 0003 0004 x=randn(1000,11); 0005 y=randn(1000,9); 0006 0007 x=nt_demean(x); 0008 y=nt_demean(y); 0009 0010 [A1,B1,R1]=canoncorr(x,y); 0011 0012 [A2,B2,R2]=nt_cca(x,y); 0013 A2=A2*sqrt(size(x,1)); 0014 B2=B2*sqrt(size(y,1)); 0015 0016 0017 figure(1); clf; 0018 subplot 211; plot([R1' R2']); 0019 if mean(A1(:).*A2(:))<0; A2=-A2; end 0020 subplot 212; plot(([x*A1(:,1),x*A2(:,1)])); 0021 0022 figure(2); clf 0023 subplot 121; 0024 imagesc(nt_cov([x*A1,y*B1])); 0025 subplot 122; 0026 imagesc(nt_cov([x*A2,y*B2])); 0027