%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');
r1 = data(5, 11:20);
r2 = data(15, 11:20);
r3 = data(24, 11:20);
r4 = data(33, 11:20);
r5 = data(42, 11:20);
r6=[6.68	11.64	9.07	8.72	13.13	9.55	9.87	5.05	3.26	5.1];
r7=[6.57	10.38	8.7	7.7	10.48	7.45	7.73	6.15	3.89	6.96];
sound_array_r=[r1;r2;r3;r4;r5;r6;r7];
n_r=[];
Rank_table_r=[];
%the for loop to get the normalized data of e and the ranking table of each
%row
for n=1:7
        t=sound_array_r(n,:);
        n_r=[n_r;t];
        g=n_r(n,:);
        [B,I]=sort(g,'descend');
        Rank_table_r=[Rank_table_r;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_R = [1 2 4 10 3 9 5 8 6 7]; %my R
standard_L = [1 3 2 10 4 5 9 6 8 7];
standard_O = [1 5 2 3 10 4 6 9 7 8];
%have a try to swap O and R
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_r=0;
diff_array_r=[];
diff_table_r=[];
for l=1:6
    m=I_standard(l,:);
    for k=1:7;
        for i=1:10;
            for j= 1:10;
                if Rank_table_r(k,j)==m(i)
                    diff_r=diff_r+(i-j)^2;
                end
            end
        end
        diff_array_r=[diff_array_r diff_r];
        diff_r=0;
    end
    diff_table_r=[diff_table_r;diff_array_r];
    diff_array_r=[];
end