求matlab高手解答自定义函数:function[Pe]=converPe(snr_in_dB)%噪声功率E = 1;snr = 10.^(snr_in_dB./10);sgma = sqrt((E./snr)/2);%帧个数frame_Num=100;frame_length = 185;%信息序列err_Num = 0;for i = 1:frame_Nums = randint(frame_lengt
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 21:25:15
求matlab高手解答自定义函数:function[Pe]=converPe(snr_in_dB)%噪声功率E = 1;snr = 10.^(snr_in_dB./10);sgma = sqrt((E./snr)/2);%帧个数frame_Num=100;frame_length = 185;%信息序列err_Num = 0;for i = 1:frame_Nums = randint(frame_lengt
求matlab高手解答
自定义函数:
function[Pe]=converPe(snr_in_dB)
%噪声功率
E = 1;
snr = 10.^(snr_in_dB./10);
sgma = sqrt((E./snr)/2);
%帧个数
frame_Num=100;
frame_length = 185;
%信息序列
err_Num = 0;
for i = 1:frame_Num
s = randint(frame_length,1,2,123);
%编码
u = GSMconv_EN(s);
% BPSK 调制
u=2.*u-1;
%经信道加高斯噪声
r = u + sgma .* randn(size(u));
% BPSK
ru = sign(r + eps);
ru = (ru + 1)/2;
%解码
Dec_s = GSMconv_DE(ru);
err_Num = err_Num + length(find(s =Dec_s(1:frame_length)));
end
%误码率
Pe =err_Num/(frame_Num*frame_length);
主函数:
snr_in_dB=-4:1:6;
err_Num =converPe(snr_in_dB);
plot(snr_in_dB,err_Num);
运算结果:
Error using ==> times
Matrix dimensions must agree.
Error in ==> converPe at 18
r = u + sgma .* randn(size(u));
自定义函数GSMconv_EN(s)
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];
求matlab高手解答自定义函数:function[Pe]=converPe(snr_in_dB)%噪声功率E = 1;snr = 10.^(snr_in_dB./10);sgma = sqrt((E./snr)/2);%帧个数frame_Num=100;frame_length = 185;%信息序列err_Num = 0;for i = 1:frame_Nums = randint(frame_lengt
很明显是你这句r = u + sgma .* randn(size(u));的u与sgma .* randn(size(u)),或者sgma .* randn(size(u))没法计算,
由于不知道你的GSMconv_EN(s);函数式什么,不知道u的行数与列数,这里关键是你要给的输入让sgma与u的行列恰当.
要求r = u + sgma .* randn(size(u));这句要求sgma的行列与u的行列一样.你好好检查下,应该可以查出来的.
希望对你有帮组