求matlab高手解答! 急啊 10
自定义函数:functionerr_rate=PrimePe2(snr_in_dB)%噪声功率E=1;snr=10.^(snr_in_dB./10);sgma=sqrt(...
自定义函数:
function err_rate=PrimePe2(snr_in_dB)
%噪声功率
E=1;
snr=10.^(snr_in_dB./10);
sgma=sqrt((E./snr)/2);
%桢个数
N=10;
%突发间隔
N_Interval=80;
%突发长度
N_Length=8;
%信息序列
signal0=[round(rand(N,185)),zeros(N,4),round(rand(N,78))];
signal=reshape(signal0',1,267*N);
%编码
for i=0:(N-1)
%卷积编码
temp0=GSMconv_EN(signal0(i+1,1:189));
temp=[temp0(1:378),signal0(i+1,190:267)];
%合成
C([1:456]+i*456)=temp(1:456);
end;
u=C;
%经信道加高斯燥声
u=2*u-1;
u=sign(u+sgma.*randn(size(u))+eps);
u=(u+1)/2;
%加突发噪声
Noise=BurstNoise(N_Interval,N_Length,length(u));
u=mod(u+Noise,2);
%解码
for n=0:(N-1)
%分离桢
ru=u([1:456]+n*456);
%卷积编码解码
des([1:267]+n*267)=[GSMconv_DE(ru(1:378)),ru(379:456)];
end;
err_rate=(length(find(signal~=des)))/length(signal);
function code = GSMconv_EN(msg)
TCH_FS_constraintlength = 5;
TCH_FS_Generator = [23 33];
trellis = poly2trellis(TCH_FS_constraintlength, TCH_FS_Generator);
REG_Num = log2(trellis.numStates);
[code1,fstate1] = convenc(msg,trellis);
[code2,fstate2] = convenc(zeros(REG_Num,1),trellis,fstate1); % 结尾比特
code =[code1 ;code2];
主函数
i=0;
for snr_in_dB=-4:1:6
i=i+1;
err_rate=PrimePe2(snr_in_dB);
end
snr_in_dB=-4:1:6;
plot(snr_in_dB,err_rate);
运行结果:
??? Error using ==> vertcat
CAT arguments dimensions are not consistent.
Error in ==> GSMconv_EN at 8
code =[code1 ;code2];
Error in ==> PrimePe2 at 18
temp0=GSMconv_EN(signal0(i+1,1:189));求matlab高手帮忙
Undefined function or variable u
Error in ==> BurstNoise at 11
Noise=BurstNoise(N_Interval,N_Length,length(u));
function N=BurstNoise(N_Interval,N_Length,Sig_Length)
%三个参数分别对应突发间隔、突发长度、信号矢量维数
%噪声
N=zeros(1,Sig_Length);
for i=1:N_Interval:Sig_Length
start_point1=round(i+N_Interval/2+(N_Interval/2)*randn);
start_point=max(i,start_point1);
end_point=min(Sig_Length,min(start_point1+N_Length,i+N_Interval-1));
N(start_point:end_point)=1;
end
%加突发噪声
Noise=BurstNoise(N_Interval,N_Length,length(u));
u=mod(u+Noise,2); 展开
function err_rate=PrimePe2(snr_in_dB)
%噪声功率
E=1;
snr=10.^(snr_in_dB./10);
sgma=sqrt((E./snr)/2);
%桢个数
N=10;
%突发间隔
N_Interval=80;
%突发长度
N_Length=8;
%信息序列
signal0=[round(rand(N,185)),zeros(N,4),round(rand(N,78))];
signal=reshape(signal0',1,267*N);
%编码
for i=0:(N-1)
%卷积编码
temp0=GSMconv_EN(signal0(i+1,1:189));
temp=[temp0(1:378),signal0(i+1,190:267)];
%合成
C([1:456]+i*456)=temp(1:456);
end;
u=C;
%经信道加高斯燥声
u=2*u-1;
u=sign(u+sgma.*randn(size(u))+eps);
u=(u+1)/2;
%加突发噪声
Noise=BurstNoise(N_Interval,N_Length,length(u));
u=mod(u+Noise,2);
%解码
for n=0:(N-1)
%分离桢
ru=u([1:456]+n*456);
%卷积编码解码
des([1:267]+n*267)=[GSMconv_DE(ru(1:378)),ru(379:456)];
end;
err_rate=(length(find(signal~=des)))/length(signal);
function code = GSMconv_EN(msg)
TCH_FS_constraintlength = 5;
TCH_FS_Generator = [23 33];
trellis = poly2trellis(TCH_FS_constraintlength, TCH_FS_Generator);
REG_Num = log2(trellis.numStates);
[code1,fstate1] = convenc(msg,trellis);
[code2,fstate2] = convenc(zeros(REG_Num,1),trellis,fstate1); % 结尾比特
code =[code1 ;code2];
主函数
i=0;
for snr_in_dB=-4:1:6
i=i+1;
err_rate=PrimePe2(snr_in_dB);
end
snr_in_dB=-4:1:6;
plot(snr_in_dB,err_rate);
运行结果:
??? Error using ==> vertcat
CAT arguments dimensions are not consistent.
Error in ==> GSMconv_EN at 8
code =[code1 ;code2];
Error in ==> PrimePe2 at 18
temp0=GSMconv_EN(signal0(i+1,1:189));求matlab高手帮忙
Undefined function or variable u
Error in ==> BurstNoise at 11
Noise=BurstNoise(N_Interval,N_Length,length(u));
function N=BurstNoise(N_Interval,N_Length,Sig_Length)
%三个参数分别对应突发间隔、突发长度、信号矢量维数
%噪声
N=zeros(1,Sig_Length);
for i=1:N_Interval:Sig_Length
start_point1=round(i+N_Interval/2+(N_Interval/2)*randn);
start_point=max(i,start_point1);
end_point=min(Sig_Length,min(start_point1+N_Length,i+N_Interval-1));
N(start_point:end_point)=1;
end
%加突发噪声
Noise=BurstNoise(N_Interval,N_Length,length(u));
u=mod(u+Noise,2); 展开
1个回答
展开全部
code =[code1 ,code2']
追问
改成你的那个,又出现了新问题,你看下补充问题那里
我已补充了BurstNoise函数,你看下怎么改
追答
GSMconv_DE函数还没有。再有
function N=BurstNoise(N_Interval,N_Length,Sig_Length)
%三个参数分别对应突发间隔、突发长度、信号矢量维数
%噪声
N=zeros(1,Sig_Length);
for i=1:N_Interval:Sig_Length
start_point1=round(i+N_Interval/2+(N_Interval/2)*randn);
start_point=max(i,start_point1);
end_point=min(Sig_Length,min(start_point1+N_Length,i+N_Interval-1));
N(start_point:end_point)=1;
end
%加突发噪声
Noise=BurstNoise(N_Interval,N_Length,length(u));
u=mod(u+Noise,2);
最后这两行能在函数内部,把这两行comment了调试程序,看还缺啥。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询