Calculating bit-error-rate of QPSK data
You're not doing anything conceptually wrong, you're just misunderstanding MATLAB. The code as you provided it doesn't execute properly; here's a fixed script:

% don't need this; MATLAB already knows what j is
%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)&gt;0.5)-1)+j*(2*(rand(1,N)&gt;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.')
sr=real(s); si=imag(s);
yr=real(y); yi=imag(y);

% it seems like you want to predeclare these since you're indexing them below
errorI = zeros(size(s));
errorQ = zeros(size(s));

for i = 1:N
    if sr(i)*yr(i)&lt;0
        errorI(i)=yr(i);
        if si(i)*yi(i)&lt;0
            errorQ(i)=yi(i);
        end
    end
end

err = errorI+j*errorQ;
% BER is the number of nonzero entries in `err` divided by the number of chances
BER = sum(err ~= 0) / length(y);