gkr
Newbie level 2
this is the bpsk code i tried in matlab.. but no output... plz help...
for j=1:7
eb1(j)=j;
no=1;
eb2(j)=10.^(eb1(j)/10);
a=sqrt(eb2(j)/4);
%s=[];
s1=[a a a a];
s2=[-a -a -a -a];
psi=[0.5 0.5 0.5 0.5];
x=0;
for i=1:10000
d=randint(i);
if d==1
s=s1;
else
s=s2;
end
n=randn(1,4);
n1=n*sqrt(no/2);
r=s+n1;
z=r.*psi;
z1=sum(z);
if(z1>0)
z=1;
else
z=0;
end
if z==d
x;
else
x=x+1;
end
end
pb(j)=x/10000;
pb(1)=qfunc(sqrt(2*eb2/no));
end
figure
semilogy(eb1,pb,'-b',eb1,pb,'--');
grid on;
title('probability error in BPSK');
xlabel('SNR in dB');
ylabel('probability error');
legend('MATLAB simulated error','ideal error');
for j=1:7
eb1(j)=j;
no=1;
eb2(j)=10.^(eb1(j)/10);
a=sqrt(eb2(j)/4);
%s=[];
s1=[a a a a];
s2=[-a -a -a -a];
psi=[0.5 0.5 0.5 0.5];
x=0;
for i=1:10000
d=randint(i);
if d==1
s=s1;
else
s=s2;
end
n=randn(1,4);
n1=n*sqrt(no/2);
r=s+n1;
z=r.*psi;
z1=sum(z);
if(z1>0)
z=1;
else
z=0;
end
if z==d
x;
else
x=x+1;
end
end
pb(j)=x/10000;
pb(1)=qfunc(sqrt(2*eb2/no));
end
figure
semilogy(eb1,pb,'-b',eb1,pb,'--');
grid on;
title('probability error in BPSK');
xlabel('SNR in dB');
ylabel('probability error');
legend('MATLAB simulated error','ideal error');