%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');
l1 = data(7, 11:20);
l2 = data(17, 11:20);
l3 = data(26, 11:20);
l4 = data(35, 11:20);
l5 = data(44, 11:20);
l6=[12.2300000000000,10.4600000000000,13.1400000000000,6.20000000000000,1.29000000000000,1.73000000000000,2.26000000000000,2.62000000000000,4.55000000000000,11.0400000000000];
l7=[10.0500000000000,9.07000000000000,12.8100000000000,5.94000000000000,2.08000000000000,1.52000000000000,1.69000000000000,1.54000000000000,2.46000000000000,5.32000000000000];
sound_array_l=[l1;l2;l3;l4;l5;l6;l7];
n_l=[];
Rank_table_l=[];
%the for loop to get the normalized data of e and the ranking table of each
%row
for n=1:7
        t=sound_array_l(n,:);
        n_l=[n_l;t];
        g=n_l(n,:);
        [B,I]=sort(g,'descend');
        Rank_table_l=[Rank_table_l;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 3 4 10 9 5 6 8 7];
standard_R = flip([8, 9, 7, 3, 6, 2, 4, 5, 1, 0])+1;
standard_L = [1 3 2 10 4 5 9 6 8 7];

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_l=0;
diff_array_l=[];
diff_table_l=[];
for l=1:6
    m=I_standard(l,:);
    for k=1:7;
        for i=1:10;
            for j= 1:10;
                if Rank_table_l(k,j)==m(i)
                    diff_l=diff_l+(i-j)^2;
                end
            end
        end
        diff_array_l=[diff_array_l diff_l];
        diff_l=0;
    end
    diff_table_l=[diff_table_l;diff_array_l];
    diff_array_l=[];
end