Please do help me regarding this coding.
I m using BPSK modulation.
the main problem is that i need to plot a graph against SNR and 10log10(ber),
kindly do check my coding and correct the code.
In this matlab coding, only transmitter and channel is coded (without reviver)
CODE:
N=1;
data=sign(2*rand(1,N)-1)
SNR = 0:20
for k=1:length(SNR)
Ns=1/10^(SNR(k)/10);
noise=sqrt(Ns)*randn(1,N);
M=8
fd=70;
wd=2*pi*fd;
N=4*M+2
for n=0:M
if n==0
w(n+1)=wd;
x(n+1)=pi/4;
b(n+1)=2^1/2*sin(x(n+1))
a(n+1)=2^1/2*cos(x(n+1))
else
w(n+1)=wd*cos(2*pi*n/N)
x(n+1)=(pi*n)/M
b(n+1)=2*sin(x(n+1))
a(n+1)=2*cos(x(n+1))
end
end
phi=(2*rand(1,M+1)-1)*pi
for t=1:N
p(t)=sum(b.*cos(w*t+phi))*2/sqrt(N)
q(t)=sum(a.*cos(w*t+phi))*2/sqrt(N)
r(t)=q(t)+j*p(t)
end
output=data.*abs(r(t))+noise;
[p,q]=find(data~=output)
error(k)=sum(p);
ber(k)=error(k)/N;
end