function[p]=ss_Pe94(snr_in_dB,Lc,A,w0)
snr=10^(snr_in_dB/10);
sgma=1;
Eb=2*sgma^2*snr;
E_chip=Eb/Lc;
N=10000;
num_of_err=0;
for i=1;N
temp=rand;
if(temp<0.5)
data=-1;
else
data=1;
end
for j=1:Lc
repeated_data(j)=data;
end
for j=1:lc
temp=rand;
if(temp<0.5)
pn_seq(j)=-1;
else
pn_seq(j)=1;
end
end
%发送信号为
trans_sig=sqrt(E_chip)*repeated-data*pn_seq;
%方差为sgma^2的高斯白噪声
noise=sgma*and(1,Lc);
%干扰
n=(i-1)*Lc+1:i*Lc;
interference=A*sin(w0*n);
rec_sig=trans_sig+nois+interference;
temp+rec_sig.*pn_seq;
decision_variable=sum(temp);
if(decision_variable<0),
decision=-1;
else
decision=1;
end
if(decision~=data)
p=num_of_err+1;
else
p=num_of_err/N;
end
Lc=20;
A1=3;
A2=7;
A3=12;
A4=0;
w0=1;
SNRindB=0:2:30;
for i=1:length(SNRindB)
smld_err_prb1(i)=ss_Pe94(SNRindB(i),Lc,A1,w0);
smld_err_prb2(i)=ss_Pe94(SNRindB(i),Lc,A2,w0);
smld_err_prb3(i)=ss_Pe94(SNRindB(i),Lc,A3,w0);
end
SNRindB4=0:1:8;
for i=1:length(SNRindB4);
smld_err_prb1(i)=ss_pe94(SNRindB(i),Lc,A4,w0);
end
end
出现如下错误提示
?? Input argument 'snr_in_dB' is undefined.
Error in ==> e:\MATLAB6p5\work\ss_Pe94.m
On line 3 ==> snr=10^(snr_in_dB/10);