%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');
a1 = data(2, 11:20);
a2 = data(12, 11:20);
a3 = data(21, 11:20);
a4 = data(30, 11:20);
a5 = data(39, 11:20);
a6=[6.29	6.74	4.57	2.29	1.57	1.95	6.6	12.79	11.57	8.7];
a7=[2.96	3.35	3.32	1.9	1.27	1.6	4.03	14.42	11.79	8.3];
sound_array_a=[a1;a2;a3;a4;a5;a6;a7];
n_a=[];
Rank_table_a=[];
%the for loop to get the normalized data of e and the ranking table of each
%row
for n=1:7
        t=sound_array_a(n,:);
        n_a=[n_a;t];
        g=n_a(n,:);
        [B,I]=sort(g,'descend');
        Rank_table_a=[Rank_table_a;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_a=0;
diff_array_a=[];
diff_table_a=[];
for l=1:6
    m=I_standard(l,:);
    for k=1:7;
        for i=1:10;
            for j= 1:10;
                if Rank_table_a(k,j)==m(i)
                    diff_a=diff_a+(i-j)^2;
                end
            end
        end
        diff_array_a=[diff_array_a diff_a];
        diff_a=0;
    end
    diff_table_a=[diff_table_a;diff_array_a];
    diff_array_a=[];
end

%A's setprev problem seems to fix now.