求救,该了很久改不出来呀!拜托了!
谢谢各位了,请帮忙哈!急需,但是改了很久改不出来,在调制那里有错,而且高斯噪声加不上呀!拜托了!f_data=1;
f_chip=11;
fc=220;
fs=3*fc;
N=fs/f_chip;
data_length=5000;
M=2;
num_of_user=4;
matches=0;
errors=0;
count=1;
SNRpbit=0;
SNR=SNRpbit;
rand('state',sum(100*colock));
randn('state',sum(100*colock));
numplot=100;
msg_unsprd=randsrc(data_length,num_of_user,);
PN_seq=(11,num_of_user,);
for s=1:num_of_user
j=1;
for i=1:data_length
for k=j:j+f_chip-1
mdg_coded(s,k)=msg_unsprd(i,s);
end;
msg_spread(s,)=xor(msg_coded(s,)',PN_seq(,s));
j=f_chip*i+1;
end;
end;
len_of_spread=length(msg_spread);
msg_tr=zeros(num_of_user,data_length*f_chip*N);
for s=1:num_of_user
msg_tr(s,:)=dmod(msg_spread(s,:),fc,f_chip,fs,'psk','M');
end;
len_of_tr=length(msg_tr);
for SNRpbit=0:1:7
SNR=SNRpbit;
rand('state',sum(100*colock));
randn('state',sum(100*colock));
msg_rec_data=zeros(num_of_user,len_of_tr);
sum_1=zeros(1,len_of_tr);
msg_received=zeros(1,len_of_tr);
for s=1:num_of_user
msg_rec_data(s,:)=awgn(msg_tr(s,:),SNR-10*log10(N),'measured','dB');
for i=1:data_length
sum_1=sum_1+msg_rec_data(s,i);
msg_received=sum_1;
end;
end;
msg_demoded=ddemod(msg_received,fc,f_chip,fs,'measured','dB');
j=1;
for i=1:data_length
msg_de_spread(j:(j+f_chip-1))=xor(msg_received(j:(j+f_chip-1))',PN_seq(1:f_chip,1));
j=f_chip*i+1;
end;
j=1;
for i=1:data_length
sum_2=0;
for k=j:j+f_chip-1
sum_2=sum_2+msg_de_spread(k);
end;
if(sum_2>=7)
msg_de_spread(i)=1;
else
msg_de_spread(i)=0;
end;
j=f_chip*i+1;
end;
for i=1:data_length
if(msg_de_spread(i)==msg_unsprd(i,1))
matches=matches+1;
else
errors=errors+1;
end;
end;
BER_awgn(count)=errors/data_length;
count=count+1;
errors=0;
end;
end;
X=;
semilogy(X,BER_awgn(count),'-.b*');
hold on;
grid on;
回复:(xianjuan)求救,该了很久改不出来呀!拜托了...
简单看了一下错误,很明显就是不仔细,比如rand('state',sum(100*colock));
randn('state',sum(100*colock));
colock写错了,是clock
PN_seq=(11,num_of_user,);
这是什么东西?有这样的表示方法吗?
msg_coded根本就没定义,是什么东西?
其他的没仔细看,自己再好好检查吧 是产生一个PN序列的做法,我打错了,但是我的源程序是对的,还有就是那个msg_coded虽然没有预定义,但是后面我对他进行负值了,我的程序主要是错在
msg_tr=zeros(num_of_user,data_length*f_chip*N);
for s=1:num_of_user
msg_tr(s,:)=dmod(msg_spread(s,:),fc,f_chip,fs,'psk','M');
end;
len_of_tr=length(msg_tr);
主要是调制那句话有问题,无法进行,前面都是对的,是我输入时马虎产生的错误,
还有就是在假如高撕噪声时出错
也就是这句化
msg_rec_data=zeros(num_of_user,len_of_tr);
sum_1=zeros(1,len_of_tr);
msg_received=zeros(1,len_of_tr);
for s=1:num_of_user
msg_rec_data(s,:)=awgn(msg_tr(s,:),SNR-10*log10(N),'measured','dB');
for i=1:data_length
sum_1=sum_1+msg_rec_data(s,i);
msg_received=sum_1;
end;
end;
拜托了,谢谢您! happy 救命呀! 将程序更正哈!说明一下,我做的多用户干扰抑制,本程序是对多用户通信的仿真,是四个用户同时通信,先对信息进行编码,然后扩频,然后进行PSK调制,然后加入高斯噪声,然后将信息进行相加,再进行解扩,再解密,然后再计算误码率,就这些了,只是在调制那里进行不下去,还有高斯噪声加不上呀!我着急,请您帮忙,拜托了!
回复:(xianjuan)求救,该了很久改不出来呀!拜托了...
<P>把你正确的程序贴一下,你说得好乱,不知道怎么个意思</P> f_data=1;f_chip=11;
fc=220;
fs=3*fc;
N=fs/f_chip;
data_length=5000;
M=2;
num_of_user=4;
matches=0;
errors=0;
count=1;
SNRpbit=0;
SNR=SNRpbit;
rand('state',sum(100*clock));
randn('state',sum(100*clock));
numplot=100;
msg_unsprd=randsrc(data_length,num_of_user,);
PN_seq=randsrc(11,num_of_user,);
for s=1:num_of_user
j=1;
for i=1:data_length
for k=j:j+f_chip-1
mdg_coded(s,k)=msg_unsprd(i,s);
end;
msg_spread(s,)=xor(msg_coded(s,)',PN_seq(,s));
j=f_chip*i+1;
end;
end;
len_of_spread=length(msg_spread);
msg_tr=zeros(num_of_user,data_length*f_chip*N);
for s=1:num_of_user
msg_tr(s,:)=dmod(msg_spread(s,:),fc,f_chip,fs,'psk','M');
end;
len_of_tr=length(msg_tr);
for SNRpbit=0:1:7
SNR=SNRpbit;
rand('state',sum(100*clock));
randn('state',sum(100*clock));
msg_rec_data=zeros(num_of_user,len_of_tr);
sum_1=zeros(1,len_of_tr);
msg_received=zeros(1,len_of_tr);
for s=1:num_of_user
msg_rec_data(s,:)=awgn(msg_tr(s,:),SNR-10*log10(N),'measured','dB');
for i=1:data_length
sum_1=sum_1+msg_rec_data(s,i);
msg_received=sum_1;
end;
end;
msg_demoded=ddemod(msg_received,fc,f_chip,fs,'measured','dB');
j=1;
for i=1:data_length
msg_de_spread(j:(j+f_chip-1))=xor(msg_received(j:(j+f_chip-1))',PN_seq(1:f_chip,1));
j=f_chip*i+1;
end;
j=1;
for i=1:data_length
sum_2=0;
for k=j:j+f_chip-1
sum_2=sum_2+msg_de_spread(k);
end;
if(sum_2>=7)
msg_de_spread(i)=1;
else
msg_de_spread(i)=0;
end;
j=f_chip*i+1;
end;
for i=1:data_length
if(msg_de_spread(i)==msg_unsprd(i,1))
matches=matches+1;
else
errors=errors+1;
end;
end;
BER_awgn(count)=errors/data_length;
count=count+1;
errors=0;
end;
end;
X=;
semilogy(X,BER_awgn(count),'-.b*');
hold on;
grid on;
拜托了
拜托了,帮忙呀!happy 救命呀!
拜托您了,急需!回复:(xianjuan)求救,该了很久改不出来呀!拜托了...
http://forum.vibunion.com/forum/viewthread.php?tid=10796
页:
[1]