function BER_for_Codes(label,decoding,filename)
%The first function to be called in this slide
%this function returns a plot of the BER(bit error rate)of different kinds of codes over an AWGN channel
%for two types of decoding : soft decision decoding and hard decision decoding
%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);
range = 1:1:10;

%l = 100000668;

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'))
l = 10000668;
b0 =BER_SNR_for_uncoded_messages(l,range) ;
b1 = BER_SNR_for_code1(l,range,2,'hard');
b2 = BER_SNR_for_code2(l,range,'hard');
b3 =BER_SNR_for_code3(l,range,'hard');
b4 =BER_SNR_for_code4(l,range,'hard');
end
if(  strcmp(decoding,'Soft-Decision'))
l = 100000668;
b0 =BER_SNR_for_uncoded_messages(l,range) ;
b1 = BER_SNR_for_code1(l,range,2,'soft');
b2 = BER_SNR_for_code2(l,range,'soft');
b3 =BER_SNR_for_code3(l,range,'soft');
b4 =BER_SNR_for_code4(l,range,'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")
figure(1);


legend({'Uncoded','Code 1', 'Code 2' ,'Code 3','Code 4'});
legend('Location','southwest');
 




xlabel(xLabel,"fontsize", 20);
ylabel('BER',"fontsize", 20);

set(gca,'YTick',[1e-1 1e-2 1e-3 1e-4 1e-5 1e-6 1e-7 1e-8]);


set(gca,'FontSize',20)
grid on;


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

end