Can you help me on this code to identify Eb_N0_dB ? I would like to know also what ipHat is.

9 ビュー (過去 30 日間)
Altin Guberi
Altin Guberi 2016 年 12 月 2 日
コメント済み: Walter Roberson 2016 年 12 月 3 日
The code is as below:
% Script for simulating binary phase shift keyed transmission and % reception and compare the simulated and theoretical bit error % probability clc;clear;close all
N = 10^8 % number of bits or symbols
rand('state',100); % initializing the rand() function
randn('state',200); % initializing the randn() function
% Transmitter
ip = rand(1,N)>0.5; % generating 0,1 with equal probability
s = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 1
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white gaussian noise, 0dB variance
Eb_N0_dB = [-3:10]; % multiple Eb/N0 values
for ii = 1:length(Eb_N0_dB)
% Noise addition
y = s + 10^(-Eb_N0_dB(ii)/20)*n; % additive white gaussian noise
% receiver - hard decision decoding
ipHat = real(y)>0;
% counting the errors
nErr(ii) = size(find([ip- ipHat]),2);
end
simBer = nErr/N; % simulated ber
theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber
% plot
close all
figure
semilogy(Eb_N0_dB,theoryBer,'b.');
hold on
%semilogy(Eb_N0_dB,simBer,'mx-');
grid on
legend('theory', 'simulation');
xlabel('SNR dB');
ylabel('BER Bit Error Rate');
title('Bit error probability curve for BPSK modulation');

回答 (1 件)

Image Analyst
Image Analyst 2016 年 12 月 2 日
You can find "Eb_N0_dB" on this line. Use the control-F command if you don't see it.
Eb_N0_dB = [-3:10]; % multiple Eb/N0 values
ipHat is defined here:
ipHat = real(y)>0;
It is a boolean/logical variable that is "true" if y has a positive real component.
Granted, the comments in this code are horrible (because there are not enough of them), and you should scold the original author for their bad programming habits.
  2 件のコメント
Altin Guberi
Altin Guberi 2016 年 12 月 3 日
So, can Eb_N0_dB be SNR ( Signal To Noise Ratio ) ??
Walter Roberson
Walter Roberson 2016 年 12 月 3 日
That is what xlabel() claims the variable represents

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePHY Components についてさらに検索

タグ

タグが未入力です。

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by