?? modulating_a_random_signal.m
字號(hào):
%% Modulating a Random Signal
% This example, aims to solve the following
% problem:
% Process a binary data stream using a communication system that
% consists of a baseband modulator, channel, and demodulator.
% Compute the system's bit error rate (BER). Also, display
% the transmitted and received signals in a scatter plot.
%% Setup
% Define parameters.
M = 16; % Size of signal constellation
k = log2(M); % Number of bits per symbol
n = 3e4; % Number of bits to process
nsamp = 1; % Oversampling rate
%% Signal Source
% Create a binary data stream as a column vector.
seeds=randint(1,1,5000);
x = randint(n,1,[0,1],seeds); % Random binary data stream
%% Bit-to-Symbol Mapping
% Convert the bits in x into k-bit symbols.
xsym = bi2de(reshape(x,k,length(x)/k).','left-msb');
%% Modulation
% Modulate using 16-QAM.
y = modulate(modem.qammod(M),xsym);
%% Transmitted Signal
ytx = y;
%% Channel
% Send signal over an AWGN channel.
EbNo =5; % In dB
snr = EbNo + 10*log10(k) - 10*log10(nsamp);
ynoisy = awgn(ytx,snr,'measured');
%% Received Signal
yrx = ynoisy;
%% Demodulation
% Demodulate signal using 16-QAM.
zsym = demodulate(modem.qamdemod(M),yrx);
%% Symbol-to-Bit Mapping
% Undo the bit-to-symbol mapping performed earlier.
z = de2bi(zsym,'left-msb'); % Convert integers to bits.
% Convert z from a matrix to a vector.
z = reshape(z.',prod(size(z)),1);
%% BER Computation
% Compare x and z to obtain the number of errors and
% the bit error rate.
[number_of_errors,bit_error_rate] = biterr(x,z);
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -