matlab误码率理论,关于误码率的问题 急!!!!!

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

求助各位大佬

要求是2ask调制 通过滚降系数为0,0.5,1的升余弦滚降滤波器,信道加入1-15db的高斯白噪声,

相干解调,匹配滤波后计算出误码率与信噪比的关系图与理论值拟合。

现在问题是计算出的误码率过高无法拟合,请教各位大佬应该怎么修改。明天就要交论文了 曲线一直拟合不上

好急

%%---baseband signal parameters---%%

D_R = 32e3; %Date Rate = 32Kbps

P_D = 1/D_R; %Pulse duration

%Signal generation

bits = 16;

rand_data = randi([0 1], 1,16);

input = repmat(rand_data',1,2000)';

input = input(:)';

t = linspace(0,bits,numel(input));

figure(1);

subplot(3,1,1);

plot(t,input);

title('Input bit stream');

xlabel('samples');

ylabel('amplitude');

grid on

%%carrier generation

fc = 10;

carrier = cos(2 * pi * fc * t);

subplot(3,1,2);

plot(t,carrier);

title('carrier');

xlabel('samples');

ylabel('amplitude');

grid;

%%raised cosine rolloff filter

%%rolloff = 0

rolloff = 0;

span = 20;

sps = 50;

rcosfilter_1 = rcosdesign(rolloff, span, sps,'sqrt');

shapedsignal_1 = conv(input,rcosfilter_1,'same');

figure(2)

subplot(3,1,1);

plot(t,shapedsignal_1);

title('shaped signal rolloff = 0');

xlabel('samples');

ylabel('amplitude');

rolloff = 0.5;

span = 20;

sps = 50;

rcosfilter_2 = rcosdesign(rolloff, span, sps,'sqrt');

shapedsignal_2 = conv(input,rcosfilter_2,'same');

subplot(3,1,2);

plot(t,shapedsignal_2);

title('shaped signal rolloff = 0.5');

xlabel('samples');

ylabel('amplitude');

rolloff = 1;

span = 20;

sps = 50;

rcosfilter_3 = rcosdesign(rolloff, span, sps,'sqrt');

shapedsignal_3 = conv(input,rcosfilter_3,'same');

subplot(3,1,3);

plot(t,shapedsignal_3);

title('shaped signal rolloff = 1');

xlabel('samples');

ylabel('amplitude');

%%ASK modulation

modulationsignal_1 = carrier .* shapedsignal_1;

figure(3);

subplot(3,1,1);

plot(t,modulationsignal_1);

title('modulation signal rolloff = 0');

xlabel('samples');

ylabel('amplitude');

grid on;

modulationsignal_2 = carrier .* shapedsignal_2;

subplot(3,1,2);

plot(t,modulationsignal_2);

title('modulation signal rolloff = 0.5');

xlabel('samples');

ylabel('amplitude');

grid on;

modulationsignal_3 = carrier .* shapedsignal_3;

subplot(3,1,3);

plot(t,modulationsignal_3);

title('modulation signal rolloff = 1');

xlabel('samples');

ylabel('amplitude');

grid on;

LPF = fdesign.lowpass('Fp,Fst,Ap,Ast',1,20,1,60,100);

lowpass = design(LPF,'equiripple');

%[ A B C D] = butter(10,[1 5]/50);

[b a] = butter(5,0.95,'low');

%d=designfilt('bandpassfir','FilterOrder',50, ...

%'CutoffFrequency1',1,'CutoffFrequency2',5, ...

%'SampleRate',100);

%%add noise

h = 1;j = 1;

for SNR = 1:1:15

snrlin = 10.^(SNR./10);

RxSig_1=awgn(modulationsignal_3,SNR,'measured',1);

%%demodulation

x = RxSig_1.* carrier;

%e = filter(d,x);

y = filter(lowpass,x);

%e = envelope(y);

z = conv(y,rcosfilter_3,'same');

%e = envelope(z);

figure(4);

subplot(4,4,SNR);

plot(t,RxSig_1,'g','LineWidth',2);

hold on;

plot(t,modulationsignal_3,'b');

title(['SNR:',num2str(SNR),'dB']);

xlabel('Samples');

ylabel('Amplitude');

%%comparator

L = length(y);

for i = 1:1:L

if z(i)> 2

output(i) = 1;

else

output(i) = 0;

end

end

figure(5);

xlabel('Samples');

ylabel('Amplitude');

subplot(5,3,SNR);

plot(t,output);

title(['SNR:',num2str(SNR),'dB'])

error = length(find(output ~= input));

cber(h) = error/32000;

h = h+1;

tber(j) = qfunc(sqrt(snrlin));

snrdb(j) = SNR;

j = j+1;

end

figure(4);

legend('Signal with noise','Signal after filteration');

figure(5);

legend('received bits with different singal to noise radio');

figure('Name','Comparison B/W Theoretical&Calculated BER');

semilogy(snrdb,cber,'-bo',snrdb,tber,'-mh');

hold on;

grid on;

legend('BER calculated','BER theoretical')

xlabel('SNR in dB');

ylabel('Bit error rate');

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MATLAB中,可以使用`qfunc`函数计算理论误码率,并使用`semilogy`函数绘制理论误码率曲线和仿真误码率曲线。下面是一个简单的例子代码: ```matlab % 设置参数 M = 2; % 调制阶数(BPSK) SNRdB = 0:2:10; % 信噪比范围 numBits = 100000; % 每个信噪比下的比特数 % 创建调制器和解调器 mod = comm.BPSKModulator(); demod = comm.BPSKDemodulator(); % 创建误码率计算器 errRate = comm.ErrorRate(); % 计算理论误码率 EbNo = 10.^(SNRdB./10); theoryBer = qfunc(sqrt(2*EbNo)); % 计算仿真误码率 for i = 1:length(SNRdB) SNR = 10^(SNRdB(i)/10); % 将dB转换为线性信噪比 noiseVar = 1/SNR; % 计算噪声方差 channel = comm.AWGNChannel('NoiseMethod','Variance','Variance',noiseVar); % 创建AWGN信道 for j = 1:numBits/M data = randi([0 M-1],M,1); % 生成M进制的随机数据 modData = mod(data); % 调制 rxData = channel(modData); % 加入噪声并接收 demodData = demod(rxData); % 解调 errRate(data,demodData); % 计算误码率 end err(i) = errRate.ErrorRate; % 记录误码率 reset(errRate); % 重置误码率计算器 end % 绘制误码率曲线 semilogy(SNRdB,err,'o-'); hold on; semilogy(SNRdB,theoryBer,'r--'); grid on; xlabel('SNR (dB)'); ylabel('BER'); legend('仿真曲线','理论曲线'); title('BPSK误码率曲线'); ``` 在这个例子代码中,我们首先设置了调制阶数、信噪比范围和每个信噪比下的比特数等参数。然后,我们创建了BPSK调制器和解调器,以及误码率计算器。接着,我们使用`qfunc`函数计算理论误码率,并在误码率计算的循环中计算仿真误码率。最后,我们将仿真误码率曲线和理论误码率曲线绘制在同一张图上,以便进行比较。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值