bits=70000; %符号数
msg=randint(bits,1,2); %随机产生的信息序列
%------------------------
SNR=0:1:12; %信噪比
L=length(SNR);
BER1=zeros(1,L);
BER2=zeros(1,L);
%-----------------------
modbit1=pskmod(msg,2); %调制
%-----------------------
for k=1:L %未编码的序列,调制后经过高斯白噪声信道,再解调制,求误码
y1=awgn(modbit1,SNR(k),'measured');%在传输序列中加入AWGN噪声
demmsg1=pskdemod(y1,2); %解调
recode=reshape(demmsg1',1,[]);
error1=(recode~=msg');
errorbits=sum(error1);
BER1(k)=errorbits/length(msg);
end
%-----------------------
code=encode(msg,15,7,'cyclic',[1 0 0 0 1 0 1 1 1]); %(15,7)循环编码
modbit2=pskmod(code,2); %调制
%-----------------------
for k=1:L %编码的序列,调制后经过高斯白噪声信道,再解调制,再纠错后求误码
y2=awgn(modbit2,SNR(k),'measured');%在传输序列中加入AWGN噪声
demmsg2=pskdemod(y2,2); %解调
recode=reshape(demmsg2',1,[]);
decodedbit=decode(recode,15,7,'cyclic',[1 0 0 0 1 0 1 1 1]);%译码
%------------------
%计算误码率
error2=(decodedbit~=msg');
errorbits=sum(error2);
BER2(k)=errorbits/length(msg);
end
%------------------------
semilogy(SNR,(BER1),'b-*')%画图
hold on
semilogy(SNR,(BER2),'r-。')
grid on
legend('未编码','(15,7)循环编码');
x1abel('SNR/dB');
y1abel('BER');
title('(15,7)循环编码性能');
怎么运行不了,求大神指点