当前位置:网站首页>Grey correlation cases and codes

Grey correlation cases and codes

2022-07-01 04:21:00 Sichuan rookie

Case study

 Insert picture description here
Find the degree of correlation between them , And size sort .

Code

Wrote notes , To view the , Changed the case , You just need to modify this part :
 Insert picture description here
Because the reading is different , You always have to change the numbers .

clc;
close;
clear all;
x=xlsread('gray_data1.xlsx');
x=x(:,2:end)';% All columns ,2 To the last row 
column_num=size(x,2);
index_num=size(x,1);

% 1、 Data averaging processing 
x_mean=mean(x,2);
for i = 1:index_num
    x(i,:) = x(i,:)/x_mean(i,1);
end
% 2、 Extract reference queue and comparison queue 
ck=x(1,:)
cp=x(2:end,:)
cp_index_num=size(cp,1);

% The comparison queue is subtracted from the reference queue 
for j = 1:cp_index_num
    t(j,:)=cp(j,:)-ck;
end
% Find the maximum difference and the minimum difference 
mmax=max(max(abs(t)))
mmin=min(min(abs(t)))
rho=0.5;
%3、 Find the correlation coefficient 
ksi=((mmin+rho*mmax)./(abs(t)+rho*mmax))

%4、 Find the correlation degree 
ksi_column_num=size(ksi,2);
r=sum(ksi,2)/ksi_column_num;

%5、 Relevance ranking , Get the results r3>r2>r1
[rs,rind]=sort(r,'descend')

Result analysis

This is the correlation size and sort ,3>2>1
 Insert picture description here

原网站

版权声明
本文为[Sichuan rookie]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202160304493469.html