MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB基础] 请高手看一下这个程序哪错了 (https://www.labfans.com/bbs/showthread.php?t=11645)

晓风残月 2010-05-29 08:42

请高手看一下这个程序哪错了
 
用bpsk调制加入高斯白噪声分析误码率,运行有错误,请高手看一下哪错了。
sr=256000.0;
ml=1;
br=sr.*ml;
nd=1000;
ebn0=0.001;
IPOINT=8;
irfn=21;
alfs=0.5;
[xh]=hrollfcoef(irfn,IPOINT ,sr,alfs,1);
[xh2]=hrollfcoef(irfn,IPOINT,sr,alfs,0);
for i=1:1:10000
data=rand(1,nd)>0.5;
data1=(data.*2)-1;
[data2]=oversamp(data1,nd,IPOINT);
data3=conv(data2,xh);
spow=sum(data3.*data3)/nd;
attn=0.5*spow*sr/br*10.^(-ebn0/10);
attn=sqrt(attn);
inoise=randn(1,length(data3)).*attn;
data4=data3+inoise;
data5=conv(data4,xh2);
sampl=irfn*IPOINT+1;
data6=data5(sampl:8:8*nd+sampl-1);
demodata=data6>0;
noe2=sum(abs(data-demodata));
nod2=length(data);
ber=noe2/nod2;
shu(1,i)=ber;
ebn0=ebn0+0.001;
%fprintf('%d\t%e\n',i,shu);
end
x=0.001:0.001:10;
y=shu;
n=3;
p=polyfit(x,y,n);
xi=linspace(0,1,1000);
z=polyval(p,xi);
plot(x,y,'o',xi,z,'k:',x,y,':r');
%legend('原始数据','3阶曲线')

%fprintf('%d\t%d\t%d\t%e\n',ebn0,noe2,nod2,noe2/nod2);
%fid=fopen('BERbpskfad.dat','a');
%fprintf(fid,'%d\t%e\t%f\t%f\t\n',ebn0,noe2,nod2,noe2/nod2);
%fclose(fid);


所有时间均为北京时间。现在的时间是 13:35

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.