MATLAB: Correlation between multiples items

correlationhelpMATLAB

Hello, Could I get a range of items less correlated from a correlation matrix?
For example from:
A, B, C, D, E … N
A,
B
C
D
E
N
Output: items less correlated are ''A,D,E''
I only need a multiple combination of items that are less correlated each others. (A – D), (A – E), (D – E)
Sorry for my English…
Thank you everyone!
Best regards

Best Answer

Use the function below to find out n least correlated items,
function findLeastCorr(corr)
% FINDLEASTCORR finds least correlated items from a given correlation matrix
% INPUT
% -----
% corr_cell - User's correlation matrix
%


% EXAMPLE
% -------
% findLeastCorr(yourCorrMatrix);
%
%
sz = size(corr);
% Sorting from lowest correlatin to highest
[~, corr_ind] = sort(corr(:));
% Finding the index of the least correlated items
prompt = 'How many least correlated items you want?';
n = input(prompt);
items = {1,1,n};
for i=1:n
[a, b] = ind2sub(sz,corr_ind(i));
items{i} = [a, b];
end
% Identify unique elements
items_mat = cell2mat(items);
items_unique = unique(items_mat);
% Displaying the items
disp(['Items less correlated are: ',num2str(items_unique(1:end))]);
end
Hope this helps!
Related Question