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];
e1=[30.4	34.04	34.4	46.32	56.07	81.38	96.33	144.49	265.68	306.32];
e2=[9.58	17.37	19.44	29.15	40.74	34.27	29.26	50.82	228.61	308.94];
e3=[29.69	28.51	39.8	69.14	158.86	147.32	72.28	104.3	252.1	504.83];
e4=[13.39	17.05	20.81	35.43	44.52	33.69	28.43	66.59	298.99	425.88];
e5=[9.3	11.64	11.3	25.62	40.44	45.44	40.59	50.22	202.72	337.23];
e6=[5.27 2.7 4.62	4.64	4.18	6.5	4.37	14.06	19.18	18.1];
e7=[5.04	4.82	3.74	3.17	6.74	5.78	6.04	16.38	18.61	12.7];
e6=e6./mel_filt_norm;
e7=e7./mel_filt_norm;
%e6 and e7 are Mel transform of Joel's voice with normalization
sound_array_e=[e1; e2; e3; e4; e5;e6;e7];
n_e=[];
Rank_table_e=[];

%the for loop to get the normalized data of e and the order table.
for n=1:7
        t=sound_array_e(n,:).*mel_filt_norm;
        n_e=[n_e;t];
        g=n_e(n,:);
        [B,I]=sort(g);
        Rank_table_e=[Rank_table_e;I];
end
%the standard array
I_a=[4 5 1 2 6 7 9 3 8 10];
I_e=[1 3 2 7 4 6 8 5 9 10];
I_r=[8 6 7 1 9 2 10 5 3 4];
I_i=[1 8 7 2 9 10 3 6 5 4];
I_o=[7 8 1 4 6 9 2 5 10 3];
I_l=[1 4 5 6 8 7 9 2 3 10];
I_standard=[I_a;I_e;I_i;I_o;I_l;I_r];


diff_e=0;
diff_array_e=[];
diff_table_e=[];
for l=1:6
    m=I_standard(l,:);
    for k=1:7;
        for i=1:10;
            for j= 1:10;
                if Rank_table_e(k,j)==m(i)
                    diff_e=diff_e+(i-j)^2;
                end
            end
        end
        diff_array_e=[diff_array_e diff_e];
        diff_e=0;
    end
    diff_table_e=[diff_table_e;diff_array_e];
    diff_array_e=[];
end