%mel_filt_norm = [1/5.5, 1/6, 1/6.5, 1/8, 1/9.5, 1/10.5, 1/12, 1/14, 1/16, 1/18.5];
data = xlsread('database_normal.xlsx');
e1_p = data(3, 11:20);
e2_p = data(13, 11:20);
e3_p = data(22, 11:20);
e4_p = data(31, 11:20);
e5_p = data(40, 11:20);
e6_p=[5.11	3.36	2.81	2.62	2.84	3.07	3.78	13.78	16.77	11.84];
e7_p=[2.83	1.82	1.54	1.19	1.31	2.66	2.91	8.7	13.67	7.6];
sound_array_e_p=[e1_p;e2_p;e3_p;e4_p;e5_p;e6_p;e7_p];
n_e_p=[];
Rank_table_e_p=[];
%the for loop to get the normalized data of e and the ranking table of each
%row
for n=1:7
        t=sound_array_e_p(n,:);
        n_e_p=[n_e_p;t];
        g=n_e_p(n,:);
        [B,I]=sort(g,'descend');
        Rank_table_e_p=[Rank_table_e_p;I];
end


%the standard array
standard_A = [9 10 8 1 2 7 3 4 6 5];
standard_E = [9 10 8 1 7 2 4 3 6 5];
standard_I = [9 1 10 8 2 3 7 4 6 5];
standard_O = [1 2 4 10 3 9 5 8 6 7];
standard_L = [1 3 2 10 4 5 9 6 8 7];
standard_R = [1 5 2 3 10 4 6 9 7 8];
I_standard=[standard_A;standard_E;standard_I;standard_O;standard_L;standard_R];
% %try to compute the square root of the different data;
% %seems to be reliable now.
diff_e_p=0;
diff_array_e_p=[];
diff_table_e_p=[];
for l=1:6
    m=I_standard(l,:);
    for k=1:7;
        for i=1:10;
            for j= 1:10;
                if Rank_table_e_p(k,j)==m(i)
                    diff_e_p=diff_e_p+(i-j)^2;
                end
            end
        end
        diff_array_e_p=[diff_array_e_p diff_e_p];
        diff_e_p=0;
    end
    diff_table_e_p=[diff_table_e_p;diff_array_e_p];
    diff_array_e_p=[];
end