📄 mqam_project_7.m
字号:
%---------------------------------------%
% Define Discrete Simulation Parameters %
%---------------------------------------%
num_pulses = 1000; % number of pulses to simulate
num_bits = num_pulses*4; % number of bits to transmit (4-ary)
num_samples_pulse = 99; % number of samples for pulse duration (note 4 bits/pulse)
pulse_rate=100; % pulses/s
pulse_period = 1/pulse_rate; % Time between pulses
sample_rate = pulse_rate*num_samples_pulse % simulation samples/sec
sample_period = 1/sample_rate; % time for each simulation sample
total_time = num_pulses * pulse_period % total simulation time
% Set up time sample array for simulation
t = [0:sample_period:total_time-sample_period];
%----------------------%
% Generate binary data %
%----------------------%
% generate binary "message"
rand('seed',1)
bit_stream = rand(1,num_bits) > .5;
% conver the binary stream into a_i and b_i values
[a,b]=QAM_bits2ab(bit_stream);
plot(a,b,'r*')
xlabel('a_i')
ylabel('b_i')
title('Transmitter Modulation Constellation')
grid
% Transmitter Modulation transition diagram
%-------------------------------%
% Create Delta Function Signals %
%-------------------------------%
% generate delta function versions of a and b
start_sample_indices = [ (num_samples_pulse+1)/2 : num_samples_pulse : length(a)*num_samples_pulse ];
a_delta = zeros(1,length(a)*num_samples_pulse);
a_delta(start_sample_indices) = a;
b_delta = zeros(1,length(b)*num_samples_pulse);
b_delta(start_sample_indices) = b;
% plot a small portion of the delata data signals
plot(t,a_delta,'r-',t,b_delta,'b-')
xlabel('t (seconds)');
ylabel('Amplitude (Volts)')
title('a_i and b_i as narrow polar pulses (almost delta functions)');
axis([.3,.5,-2,2]);
legend('a_i','b_i')
%-------------------------%
% Generate pulse waveform %
%-------------------------%
% Generate single raised cosine pulse
%---------------------%
% Perform line coding %
%---------------------%
% Form transmitted signal
% convolve delta signals with pulse
% perform carrier modulation
%------------------%
% Simulate Channel %
%------------------%
% Form received signal
% Channel BPF and noise
%--------------%
% Demodulation %
%--------------%
% Get m1 and m2 signals
%-------------------%
% Decode Bit Stream %
%-------------------%
% Convert back to bit stream
bits_out=QAM_ab2bits(m1(start_sample_indices),m2(start_sample_indices));
% Compare with input bit stream to find bit errors
pe = bit_error_probability(bit_stream,bits_out)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -