%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');
i1 = data(4, 11:20);
i2 = data(14, 11:20);
i3 = data(23, 11:20);
i4 = data(32, 11:20);
i5 = data(41, 11:20);
i6=[3.87	4.55	3.46	1.95	2.51	3.41	8.19	7.29	6.36	11.61];
i7=[6.45	7.86	4.11	3.81	2.25	5.31	14.38	11.44	8.37	9.11];
sound_array_i=[i1;i2;i3;i4;i5;i6;i7];
n_i=[];
Rank_table_i=[];
%the for loop to get the normalized data of e and the ranking table of each
%row
for n=1:7
        t=sound_array_i(n,:);
        n_i=[n_i;t];
        g=n_i(n,:);
        [B,I]=sort(g,'descend');
        Rank_table_i=[Rank_table_i;I];
end


%the standard array
standard_A = [9 10 8 1 2 7 3 4 6 5];
standard_E = [9 10 1 8 2 3 7 4 5 6];
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_i=0;
diff_array_i=[];
diff_table_i=[];
for l=1:6
    m=I_standard(l,:);
    for k=1:7;
        for i=1:10;
            for j= 1:10;
                if Rank_table_i(k,j)==m(i)
                    diff_i=diff_i+(i-j)^2;
                end
            end
        end
        diff_array_i=[diff_array_i diff_i];
        diff_i=0;
    end
    diff_table_i=[diff_table_i;diff_array_i];
    diff_array_i=[];
end