资源简介
matlab 典型相关分析 cca Canonical correlation analysis
代码片段和文件信息
function [Wx Wy r] = cca(XY)
% CCA calculate canonical correlations %
% [Wx Wy r] = cca(XY) where Wx and Wy contains the canonical correlation
% vectors as columns and r is a vector with corresponding canonical
% correlations. The correlations are sorted in descending order. X and Y
% are matrices where each column is a sample. Hence X and Y must have
% the same number of columns. %
% Example: If X is M*K and Y is N*K there are L=MIN(MN) solutions. Wx is
% then M*L Wy is N*L and r is L*1. % % % ?2000 Magnus Borga link鰌ings universitet
% --- Calculate covariance matrices ---
z = [X;Y];
C = cov(z.‘);
sx = size(X1);
sy = size(Y1);
Cxx = C(1:sx 1:sx) + 10^(-8)*eye(sx);
Cxy = C(1:sx sx+1:sx+sy);
Cyx = Cxy‘;
Cyy = C(sx+1:sx
评论
共有 条评论