function BER_for_Code1(label,decoding,filename)
%The first function to be called in this slide
%this function returns a plot of BER of several repetition codes after transmission 
%over an BI-AWGN channel with hard/soft decision-output
%Inputs defined by the user from the webdemo page:
%label:SNRb or SNRs(signal-to-noise ratio) in dB with SNRs=SNRb+10*log10(1/2);
%decoding:type of decoding (soft or hard)

range = 1:1:12;
l = 10000032;
line = 2;
xLabel = 'E_s / N_0 in dB';
if(label ==1)
    line = 1;
    xLabel = 'E_b / N_0 in dB';
end
if(  strcmp(decoding,'Hard-Decision'))
b0 =BER_SNR_for_uncoded_messages(l,range) ;
b1 = BER_SNR_for_code1(l,range,3,'hard');
b2 = BER_SNR_for_code1(l,range,7,'hard');
b3 =BER_SNR_for_code1(l,range,9,'hard');
b4 =BER_SNR_for_code1(l,range,11,'hard');
end
if(  strcmp(decoding,'Soft-Decision'))
b0 =BER_SNR_for_uncoded_messages(l,range) ;
b1 = BER_SNR_for_code1(l,range,3,'soft');
b2 = BER_SNR_for_code1(l,range,7,'soft');
b3 =BER_SNR_for_code1(l,range,9,'soft');
b4 =BER_SNR_for_code1(l,range,11,'soft');
end
set (0, "defaultaxesfontname", "Helvetica")
set (0, "defaultaxesfontsize", 20)
set (0, "defaulttextfontname", "Helvetica")
set (0, "defaulttextfontsize", 20) 
fh = figure(1);

figure(1);
semilogy(b0 (line,:), b0 (3,:),' --',"LineWidth",14, "color","k"); hold all
figure(1);
semilogy(b1 (line,:), b1 (3,:),"LineWidth",14, "color","g")
figure(1);
semilogy(b2 (line,:), b2(3,:),"LineWidth",14, "color","r")
figure(1);
semilogy(b3 (line,:), b3 (3,:),"LineWidth",14, "color","b")
figure(1);
semilogy(b4 (line,:), b4 (3,:),"LineWidth",14, "color","m")

ylim ([1e-6 1e-1]);

legend({'Uncoded','n=3', 'n=7' ,'n=9','n=11'});
legend('Location','southwest');

print("plot.eps","-deps", "-F:30")
xlabel(xLabel,"fontsize", 20);
ylabel('BER',"fontsize", 20);
%set(findall(gca, 'Type', 'Line'),'LineWidth',2.5);
set(gca,'FontSize',20)
grid on;


print(filename, '-dpng','-r72');
    
    

end