this is $ qam modulation and bit error rate curve it will help u]you.%% 4QAM using correlation metric
clc
close all
clear all
N =10^ 5; % number of bits or symbols
Eb_N0_dB =-20:-5; % multiple Eb/N0 values
snr=Eb_N0_dB;
%% signals and their apriori defined for QAM
s2=1+j;
s0=-1+j;
s1=-1-j;
s3=1-j;
for i= 1:length(snr)
%% Transmitter
m=randint(1,N,4);%signal generation
%bits mapped to complex no
s=qammod(m,4);
% depending on the value of snr np is being calculated
a=10^(-snr(i)/20);
%complex random noise is being generated here
w=1/sqrt(2)*(randn(1,N)+sqrt(-1)*randn(1,N));%+sqrt(-1))*a/sqrt(2);
%signal transmitted through AWGN channel
y=s+a*w;
%%
v0=[real(s0);imag(s0)];
v1=[real(s1);imag(s1)];
v2=[real(s2);imag(s2)];
v3=[real(s3);imag(s3)];
for k=1:N,
y_r=real(y(k));
y_im=imag(y(k));
r=[y_r;y_im ];
if ((r'*v0>r'*v1) & (r'*v0>r'*v2) & (r'*v0>r'*v3))
rhat(k)=s0;
elseif ((r'*v1>r'*v0) & (r'*v1>r'*v2) &(r'*v3>r'*v3))
rhat(k)=s1;
elseif ((r'*v2>r'*v0) & (r'*v2>r'*v1) &(r'*v2>r'*v3))
rhat(k)=s2;
else
rhat(k)=s3;
end
end
m_hat=qamdemod(rhat,4);
% counting the errors
nerr(i)=sum(xor(m_hat,m));
end
ber = nerr/N; % simulated ber
% plot
close all
figure
semilogy(snr,ber,'m');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('Bit error probability curve for BPSK modulation');