    clear all
    clc
load('awgn+none+0.mat');


results.SNR = SNR;
   
    
   for i_mcs = 1:1
    for i_N_ss = 1:length(SpatialStreams)
               
                figure (1);
                subplot(1,1,1);
                
                color_line = [0:6 0:6];
                color_line = de2bi(color_line(i_N_ss),3);
                marker_line = ['+' '+' '+' '+' '+' '+' '+' 'o' 'o' 'o' 'o' 'o' 'o' 'o'];
                
                lgnd = strcat({'BER PSDU for '},num2str(i_N_ss),{' spatial stream(s)'}); 
                semilogy(SNR,results.ber_PSDU(1,:,i_N_ss,i_mcs),'Color',color_line,'LineStyle','-','Marker',marker_line(i_N_ss),'LineWidth',3,'MarkerSize',6,'DisplayName',lgnd)
                hold on
                
                
                %color_line = randi(7);
                %color_line = de2bi(color_line,3);
                figure (2);
                subplot(1,1,1); 
                
                lgnd = strcat({'FER PSDU for '},num2str(i_N_ss),{' spatial stream(s)'});
                semilogy(SNR,results.fer_frames_PSDU(1,:,i_N_ss,i_mcs),'Color',color_line,'LineStyle','-','Marker',marker_line(i_mcs),'LineWidth',3,'MarkerSize',6,'DisplayName',lgnd)
                hold on
                
                figure (3);
                subplot(1,1,1);
                
                lgnd = strcat({'Throughput PSDU for '},num2str(i_N_ss),{' spatial stream(s)'});
                plot(SNR,(results.throughput_PSDU(1,:,i_N_ss,i_mcs)./10^6),'Color',color_line,'LineStyle','-','Marker',marker_line(i_mcs),'LineWidth',3,'MarkerSize',6,'DisplayName',lgnd)
                hold on
                
            end   
            figure (1);
            if strcmp(channelType,'fad')
            EbN0Lin = 10.^(SNR/10);
            theoryBer = 0.5.*(1-sqrt(EbN0Lin./(EbN0Lin+1)));
            lgnd = strcat({'Theoretical BER for Rayling channel'});
            
            else 
               
            theoryBer = 0.5*erfc(sqrt(1*10.^(SNR/10)));
            lgnd = strcat({'Theoretical BER for AWGN channel'});
            end
            
            semilogy(SNR,theoryBer,'Color','blue','LineStyle',':','LineWidth',3,'MarkerSize',6,'DisplayName',lgnd);
            
            axis([-5 11 10^(-4) 1])
            grid on
            set(gca,'fontsize',25)
            xlabel('SNR [dB]')
            ylabel('BER [-]')
            lgnd = legend('show');
            title(['BER vs SNR for ',wifi_params.MCS(i_mcs).MCS])
          
            figure (2);
            axis([0 8 10^(-2) 1])
            grid on
            set(gca,'fontsize',25)
            xlabel('SNR [dB]')
            ylabel('FER [-]')
            lgnd = legend('show');
            title(['FER vs SNR for ',wifi_params.MCS(i_mcs).MCS])
            
            figure (3);
            axis([-5 10 10^(0) 60])
            grid on
            set(gca,'fontsize',25)
            xlabel('SNR [dB]')
            ylabel('Throughput [Mbit/s]')
            lgnd = legend('show');
            title(['Throughput vs SNR for ',wifi_params.MCS(i_mcs).MCS])
            
    end
            hold off
           