clear all;
SNRv=[10 20 30 40 50];
Iter=length(SNRv);
K=4;
seedini=sum(10*clock);
delay=[0 4e-6/320*4  4e-6/320*8 4e-6/320*10];
%delay=[0 4e-6/320*1 4e-6/320*4 4e-6/320*8 4e-6/320*19 4e-6/320*34];
gain=[0 -11 -180  -200];
%gain=[0 -11 -15  -18  -20  -20 ];
for a = 1:Iter,
    SNRn=SNRv(a);
    for b=1:K,
    seedfad=ceil(seedini+100*b);
    sim ofdmls502;
	n=length(ber_2);
    BER_2ND(a, b)=ber_2(n,1);
    n=length(ber_lin);
    BER_LINEAR(a,b)=ber_lin(n,1);
    n=length(ber_lps);
    BER_LOWPASS(a,b)=ber_lps(n,1);
    n=length(ber_spline);
    BER_SPLINE(a,b)=ber_spline(n,1);
    end
    avg_ber_2order(a)=sum(BER_2ND(a,:))/K;
    avg_ber_lin(a)=sum(BER_LINEAR(a,:))/K;
    avg_ber_lps(a)=sum(BER_LOWPASS(a,:))/K;
    avg_ber_spline(a)=sum(BER_SPLINE(a,:))/K;
end
num_bit_atest=ber_lin(n,3);
save OFDMLS502_2path SNRv BER_2ND BER_LINEAR BER_LOWPASS BER_SPLINE avg_ber_spline avg_ber_2order avg_ber_lin avg_ber_lps delay gain;

clear all;
SNRv=[10 20 30 40 50];
Iter=length(SNRv);
delay=[0 4e-6/320*4  4e-6/320*8 4e-6/320*10];
%delay=[0 4e-6/320*1 4e-6/320*4 4e-6/320*8 4e-6/320*19 4e-6/320*34];
gain=[0 -11 -180  -200];
%gain=[0 -11 -15  -18  -20  -20 ];
K=4;
seedini=sum(10*clock);
for a = 1:Iter,
    SNRn=SNRv(a);
    for b=1:K,
    seedfad=ceil(seedini+100*b);
    sim ofdmlms502;
	n=length(ber_2);
    BER_2ND(a, b)=ber_2(n,1);
    n=length(ber_lin);
    BER_LINEAR(a,b)=ber_lin(n,1);
    n=length(ber_lps);
    BER_LOWPASS(a,b)=ber_lps(n,1);
    n=length(ber_spline);
    BER_SPLINE(a,b)=ber_spline(n,1);
    end
    avg_ber_2order(a)=sum(BER_2ND(a,:))/K;
    avg_ber_lin(a)=sum(BER_LINEAR(a,:))/K;
    avg_ber_lps(a)=sum(BER_LOWPASS(a,:))/K;
    avg_ber_spline(a)=sum(BER_SPLINE(a,:))/K;
end
num_bit_atest=ber_lin(n,3);
save OFDMLMS502_2path SNRv BER_2ND BER_LINEAR BER_LOWPASS BER_SPLINE avg_ber_spline avg_ber_2order avg_ber_lin avg_ber_lps delay gain;
