我正在尝试使用以下函数从数据中查找和删除相关列
function [ correlated ] = correlated( data, threshold )
% data is m x m matrix
% threshold is correlation threshold
c=corr(data);
[i,j] = find(c>threshold);
A = [i,j];
A=A(find(arrayfun(@(i)length(unique(A(i,:))),1:size(A,1))==size(A,2)),:);
% as A also includes 1 1; 2 2; 3 3; etc so I used above line that I found somewhere
% 6 4
% 8 4
% 4 6
% 8 6
% 4 8
% 6 8
% 14 11
% 11 14
% it should not contain both 6 4; and 4 6; how do I remove all such rows?
end
它不应包含6 4;和4 6;如何删除所有这些行?
答案 0 :(得分:4)
uniqueA = unique(sort(A,2), 'rows');