값 당신은 당신이 CovMatrix(:,3)
의 상관 값으로 구성된 셀 어레이와 CovMatrix(:,1)
의 상관 관계 CovMatrix(:,2)
계산에 사용 된 데이터의 이름으로 끝날 것이다 다음 코드를 실행하면 :표
clear all
FieldName = {'Name1','Name2','Name3','Name4','Name5'};
Data={rand(12,1),rand(12,1),rand(12,1),rand(12,1),rand(12,1)};
DataCell = [FieldName;Data];%place in a structure - this is the same
%structure that the data for the lakes will be placed in.
DataStructure = struct(DataCell{:});
FieldName = fieldnames(DataStructure);
Combinations = nchoosek (1:numel(FieldName),2);
d1 = cell2mat(struct2cell(DataStructure)');%this will be the surface temperatures
%use the combinations found in 'Combinations' to define which elements to
%use in calculating the coherence.
R = cell(1,size(Combinations,1));%pre-allocate the cell array
Names1 = cell(1,size(Combinations,1));
for j = 1:size(Combinations,1);
[R{j},P{j}] = corrcoef([d1(:,[Combinations(j,1)]),d1(:,[Combinations(j,2)])]);
Names1{j} = ([FieldName([Combinations(j,1)],1),FieldName([Combinations(j,2)],1)]);
end
%only obtain a single value for the correlation and p-value
for i = 1:size(Combinations,1);
R{1,i} = R{1,i}(1,2);
P{1,i} = P{1,i}(1,2);
end
R = R';P = P';
%COVARIANCE MATRIX
CovMatrix=cell(size(Combinations,1),3);%pre-allocate memory
for i=1:size(Combinations,1);
CovMatrix{i,3}=R{i,1};
CovMatrix{i,1}=Names1{1,i}{1,1};
CovMatrix{i,2}=Names1{1,i}{1,2};
end
을
이것으로부터, 바람직하게는 상관 행렬의 형태로 값의 테이블을 생성 할 필요가 있습니다. 이것은 jeremytheadventurer.blogspot.com와 유사합니다. 이것이 MATLAB에서 가능한가?
이전 [질문] (http://stackoverflow.com/questions/8851290/correlation-in-matlab)의 반복처럼 보입니다. 좋은 대답을 얻지 못한 이유는 아마도 질문이 명확하지 않고 코드 예제가 복잡해야하기 때문일 것입니다. – Kavka
명확하지 않을 수 있습니다. 코드는 결과를 산출하는 예제 코드 일 뿐이며 코드 구조는 부적합합니다. 'CovMatrix'결과에서 링크에 표시된 표로 이동할 수 있는지 묻는 것입니다. 복잡한? – user1053544