function BER_delta_for_Codes_BSC(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 a channel
%Inputs defined by the user from the webdemo page:
%min is the minimal value of delta(error probability)/epsilon(erasure probability)
%max is the minimal value of delta(error probability)/epsilon(erasure probability)
%channel is the channel type:BSC or BEC



channel = 'BSC';


range=[1e-4 1e-3 1e-2 1e-1];

l = 10000032;

b0 =BER_delta_for_uncoded_messages(l,range,channel) ;
b1 = BER_delta_for_code1(l,range,2,channel);
b2 = BER_delta_for_code2(l,range,channel);
b3 =BER_delta_for_code3(l,range,channel);
b4 =BER_delta_for_code4(l,range,channel);
set (0, "defaultaxesfontname", "Helvetica")
set (0, "defaultaxesfontsize", 20)
set (0, "defaulttextfontname", "Helvetica")
set (0, "defaulttextfontsize", 20) 
fh = figure(1);
figure(1); 
semilogy(b0 (1,:), b0 (2,:),'--',"LineWidth",14, "color","k"); hold all
figure(1);
 semilogy(b1 (1,:), b1 (2,:),"LineWidth",14, "color","g")
figure(1); 
semilogy(b2 (1,:), b2(2,:),"LineWidth",14, "color","r");
figure(1);
 semilogy(b3 (1,:), b3 (2,:),"LineWidth",14, "color","b")
figure(1); 
semilogy(b4 (1,:), b4 (2,:),"LineWidth",14, "color","m")
 
l=legend('Uncoded','Code 1', 'Code 2' ,'Code 3','Code 4');
legend('Location','southwest');
%print("plot.eps","-deps", "-F:30") 
if(  strcmp(channel,'BSC'))
    xlabel('BSC error probability',"fontsize", 20);
end
if(  strcmp(channel,'BEC'))
    xlabel('BEC erasure probability',"fontsize", 20 );
end

ylabel('BER',"fontsize", 20)
%set(findall(gca, 'Type', 'Line'),'LineWidth',2.5);
set(gca,'FontSize',20)
grid on;

set(gca, 'XScale', 'log')
set(gca, 'Xdir', 'reverse')
print(filename,  '-dpng','-r72');

end