Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Task 1.1
- clc;
- clear all;
- close all;
- EbN0 = linspace(-5,10,16);
- %EbN0 = linspace(10^(-0.5),10,16);% from -5 to 10 dB.
- Pe = qfunc(sqrt(2 * 10.^(EbN0/10)));
- semilogy(EbN0,Pe)
- xlabel('$\displaystyle\frac{E_b}{N_0}$ [dB]','interpreter','latex');
- ylabel("Pe");
- hold on
- %% Task 1.2
- mu = 0;
- Error = zeros(1,16); % Vector where we count number of bit errors
- %Pe = zeros(1,16);
- for i = 1:16 % We want to loop for each SNR N times
- SNR = 10.^(EbN0(i)/10);
- N0 = 1/SNR;
- sigma = sqrt(N0/2);
- for N = 1:100000
- s = randi([-1 1]); % We transmit 1 or -1.
- while s == 0
- s = randi([-1 1],1);
- end
- noise = normrnd(mu,sigma);
- x = s + noise; % We add noise and receive x.
- if(sign(x) ~= sign(s)) %If true we recieved wrong.
- Error(i) = Error(i) + 1;
- end
- end
- Pe1(i) = Error(i)/100000;
- end
- semilogy(EbN0,Pe1)
- ylim([10^(-4) 1]);
- legend("Exact","Experimentally")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement