I am working on a simulation of QPSK data using the code below (Matlab):
j = sqrt(-1); N = 10^6; % number of symbols Es_N0_dB = 12; % ratio of signal energy to noise energy in dB QP = (2*(rand(1,N)>0.5)-1)+j*(2*(rand(1,N)>0.5)-1); % actual QPSK data s = (1/sqrt(2))*QP; % normalization of energy to 1 n = 1/sqrt(2)*(randn(1,N)+j*randn(1,N)); % white Gaussian noise, 0 dB variance y = s + 10^(-Es_N0_dB/20)*n; % recovered noisy data plot(y, 'b.')
This is my resulting constellation diagram:
To identify the errors (and calculating the bit-error-rate), I have divided the diagram into 4 quadrants and used the following to find out which elements have changed sign (i.e. crossed the decision boundaries):
sr=real(s); si=imag(s); yr=real(y); yi=imag(y); for i = 1:N if sr(i)*yr(i)<0 errorI(i)=yr(i); if si(i)*yi(i)<0 errorQ(i)=yi(i); end end end err = errorI+j*errorQ; BER = numel(err)/numel(y);
However, this does not return any data for the in-phase and quadrature errors. What is the problem with this approach?
Any explanation would be greatly appreciated.