[讨论]多用户通信的仿真
<P>将程序更正哈!说明一下,我做的多用户干扰抑制,本程序是对多用户通信的仿真,是四个用户同时通信,先对信息进行编码,然后扩频,然后进行PSK调制,然后加入高斯噪声,然后将信息进行相加,再进行解扩,再解密,然后再计算误码率,就这些了,只是在调制那里进行不下去,还有高斯噪声加不上呀!我着急,请您帮忙,拜托了!<br><br><br>是产生一个PN序列的做法,我打错了,但是我的源程序是对的,还有就是那个msg_coded虽然没有预定义,但是后面我对他进行负值了,我的程序主要是错在<br>msg_tr=zeros(num_of_user,data_length*f_chip*N);<br>for s=1:num_of_user<br> msg_tr(s,:)=dmod(msg_spread(s,:),fc,f_chip,fs,'psk','M');<br>end;<br>len_of_tr=length(msg_tr);<br>主要是调制那句话有问题,无法进行,前面都是对的,是我输入时马虎产生的错误,<br>还有就是在假如高撕噪声时出错<br>也就是这句化<br>msg_rec_data=zeros(num_of_user,len_of_tr);<br>sum_1=zeros(1,len_of_tr);<br>msg_received=zeros(1,len_of_tr);</P><P>for s=1:num_of_user<br> msg_rec_data(s,:)=awgn(msg_tr(s,:),SNR-10*log10(N),'measured','dB');<br> for i=1:data_length<br> sum_1=sum_1+msg_rec_data(s,i);<br> msg_received=sum_1;<br> end;<br>end;<br>拜托了,谢谢您!</P>
[此贴子已经被aspen于2006-4-18 14:52:41编辑过]
回复:(xianjuan)happy 救命!
<P>把你正确的程序贴一下,你说得好乱,不知道怎么个意思</P> <P>f_data=1;<BR>f_chip=11;<BR>fc=220;<BR>fs=3*fc;<BR>N=fs/f_chip;<BR>data_length=5000;<BR>M=2;<BR>num_of_user=4;<BR>matches=0;<BR>errors=0;<BR>count=1;<BR>SNRpbit=0;<BR>SNR=SNRpbit;</P><P>rand('state',sum(100*clock));<BR>randn('state',sum(100*clock));<BR>numplot=100;<BR>msg_unsprd=randsrc(data_length,num_of_user,);%生成原始用户数据<BR>PN_seq=randsrc(11,num_of_user,);%生成每个用户的扩频序列</P>
<P>for s=1:num_of_user<BR> j=1;<BR> for i=1:data_length<BR> for k=j:j+f_chip-1<BR> mdg_coded(s,k)=msg_unsprd(i,s);%编码,将每个数据变为11位<BR> end;<BR> msg_spread(s,)=xor(msg_coded(s,)',PN_seq(,s));%将每个用户实现扩频<BR> j=f_chip*i+1;<BR> end;<BR>end;<BR>len_of_spread=length(msg_spread);</P>
<P>msg_tr=zeros(num_of_user,data_length*f_chip*N);<BR>for s=1:num_of_user<BR> msg_tr(s,:)=dmod(msg_spread(s,:),fc,f_chip,fs,'psk','M');%调制,这句有错<BR>end;<BR>len_of_tr=length(msg_tr);</P>
<P>for SNRpbit=0:1:7<BR> SNR=SNRpbit;<BR> rand('state',sum(100*clock));<BR> randn('state',sum(100*clock));<BR> <BR>msg_rec_data=zeros(num_of_user,len_of_tr);<BR>sum_1=zeros(1,len_of_tr);<BR>msg_received=zeros(1,len_of_tr);</P>
<P>for s=1:num_of_user<BR> msg_rec_data(s,:)=awgn(msg_tr(s,:),SNR-10*log10(N),'measured','dB');%加高斯噪声,这句有错<BR> for i=1:data_length<BR> sum_1=sum_1+msg_rec_data(s,i);<BR> msg_received=sum_1;<BR> end;<BR>end;</P>
<P> msg_demoded=ddemod(msg_received,fc,f_chip,fs,'measured','dB');%解调,有错</P>
<P>j=1;<BR>for i=1:data_length<BR> msg_de_spread(j:(j+f_chip-1))=xor(msg_received(j:(j+f_chip-1))',PN_seq(1:f_chip,1));%解扩,以第一个用户为期望用户<BR> j=f_chip*i+1;<BR>end;</P>
<P>j=1;<BR>for i=1:data_length<BR> sum_2=0;<BR> for k=j:j+f_chip-1<BR> sum_2=sum_2+msg_de_spread(k);%解密<BR> end;<BR>if(sum_2>=7)<BR> msg_de_spread(i)=1;<BR>else<BR> msg_de_spread(i)=0;<BR>end;<BR>j=f_chip*i+1;<BR>end;</P>
<P>for i=1:data_length<BR> if(msg_de_spread(i)==msg_unsprd(i,1))<BR> matches=matches+1;<BR> else<BR> errors=errors+1;<BR> end;<BR>end;<BR>BER_awgn(count)=errors/data_length;%计算误码率<BR> count=count+1;<BR> errors=0;<BR>end;<BR>end;<BR> X=;<BR> semilogy(X,BER_awgn(count),'-.b*');%画图<BR> hold on;<BR> grid on;<BR><BR>拜托了!</P>
回复:(xianjuan)[讨论]多用户通信的仿真
在你的程序中没有找到msg_coded赋值地方啊<BR>另外对msg_coded的赋值必须在<BR>msg_spread(s,)=xor(msg_coded(s,)',PN_seq(,s));%将每个用户实现扩频<BR>这个语句之前 我也去看看
页:
[1]