Lab 3: Baseband Channel Modeling
In this lab, you will learn how to:
Compute a complex baseband equivalent channel for a multi-tap passband channel
Simulate the complex baseband channel in discrete time
Plot the frequency response of the channel
Visualize the effect of the channel on the PSD
Contents
Generate random complex baseband signals
Find a baseband equivalent channel of a multipath wireless channel
Simulate the channel in discrete-time
Plotting the PSD of the TX and RX signal
Plot the frequency response of the effective baseband channel
Confirm the PSD formula
Generate random complex baseband signals
For a complex baseband waveform, we will use signal x(t) that has real and imaginary parts with values +/-1 that change every
1$\mu$s. The signal is sampled at 10 MHz.
fs = 10; % sample rate for the simulation (in MHz)
nsamp_per_sym = 10; % number of samples per symbol
nsym = 1000; % number of symbols
% Generate random symbol values
xsymc = 2*(rand(nsym,1) > 0.5)-1;
xsyms = 2*(rand(nsym,1) > 0.5)-1;
xsym = xsymc + 1i*xsyms;
% Now repeat the values in the symbol
% If you have the most recent version of MATLAB, you can use repelem.
x = repmat(xsym.',nsamp_per_sym,1);
%x = x(:);
x = reshape(repmat(xsym.', nsamp_per_sym, 1), [], 1); % Column vector
Find a baseband equivalent channel of a multipath wireless channel
Wireless channels are often modeled as a sum of paths, each path having some delay and gain. This passband channel can be
described as:
y_p(t) = \sum_n gainp(n)*x_p(t-dly(n))
where x_p(t) and y_p(t) are the TX and RX passband signals. Assume the following parameters:
gainp = [1 0.5]'; % Vector of path gains in linear units for each path
dly = [0 0.5]'; % Vector of path delays in us.
fc = 100; % Carrier frequency in MHz
% TODO: Find a vector gainb such that the
% baseband equivalent channel is:
%
% v(t) = \sum_n gainb(n)*x(t-dly(n))
% y(t) = LPF{v(t)}
%
% The relationship between gainb(t) and gainp(t) can be written as
% gainb(t) = gainp(t)*exp(-i*2*pi*fc*t)
% gainb = ...
gainb = gainp .* exp(-1i*2*pi*fc*dly); % Baseband gains
% We design the low-pass filter for the downconversion
flp = 1.5; % cut-off frequency (in MHz) for the low-pass filter
nlp = 4; % filter order
rip = 0.5; % passband ripple
flp_norm = flp/fs*2; % normalized cut-off frequency
[blp,alp] = cheby1(nlp,0.5,flp_norm);
Simulate the channel in discrete-time
To simulate the delays in discrete-time, we need to quantize the delays. TODO: Find a vector dly_samp such that, in discrete
time
v(k) = \sum_n gainb(n)*x(k -dly_samp(n))
y(k) = LPF{v(k)}
dly_samp = ...
dly_samp = round(dly * fs); % Samples = μs * MHz
% TODO: Perform the sum above to create the output signal v(k)
% You can use a for loop over the paths adding shifted and delayed versions
% of x. The final signal v should have the same length as the original
% signal x. To do this, pad the shifted copies of x with zeros when you
% shift them to the right.
% v = ...
v = zeros(size(x));
for n = 1:length(gainb)
shift = dly_samp(n);
% Shift x by 'shift' samples (zero-pad at start)
x_shifted = [zeros(shift,1); x(1:end-shift)];
v = v + gainb(n) * x_shifted;
end
% TODO: Filter the signal v with the low-pass filter to create a signal y.
% y = ...
flp = 1.5; % Cutoff (MHz)
flp_norm = flp/(fs/2); % Normalized cutoff
[blp, alp] = cheby1(4, 0.5, flp_norm); % Filter design
y = filter(blp, alp, v); % Filtered output
% TODO: Plot the time domain signal y for the time $t \in [100,150] \mu$s.
% Plot the real and imaginary parts separately using the subplt command.
t_samples = 1000:1500; % 100-150 μs at 10 MHz
t_micro = t_samples/fs;
figure;
subplot(2,1,1);
plot(t_micro, real(y(t_samples)));
title('Real Part of y(t)');
xlabel('Time (μs)');
subplot(2,1,2);
plot(t_micro, imag(y(t_samples)));
title('Imaginary Part of y(t)');
xlabel('Time (μs)');
Plotting the PSD of the TX and RX signal
TODO: plot the PSD of x(t) and y(t) on the same graph
Sx = ...
Sy = ...
nfft = 1024;
f = linspace(-fs/2, fs/2, nfft)';
[Sx, f] = pwelch(x, hann(nfft), nfft/2, f, fs);
[Sy, f] = pwelch(y, hann(nfft), nfft/2, f, fs);
figure;
plot(f, 10*log10(Sx), 'b', f, 10*log10(Sy), 'r');
axis([-fs/2 fs/2 -60 20]);
legend('TX (x)', 'RX (y)');
xlabel('Frequency (MHz)');
ylabel('PSD (dB)');
Plot the frequency response of the effective baseband channel
% TODO: Compute the frequency response of Hchan(f)=V(f)/X(f)
% Use the specified frequencies f. You can do this by summing over the
% paths.
% Hchan = ...
Hchan = zeros(nfft,1);
for n = 1:length(gainb)
Hchan = Hchan + gainb(n)*exp(-1i*2*pi*f*dly(n));
end
% TODO: Compute the frequency response of Hlpf(f)=Y(f)/V(f).
% Use the freqz command on the filter coefficients blp and alp.
% To make sure the frequency response is given for -fs/2 to fs/2,
% use the 'whole' option in freqz. Then, use the fftshift to center the
% result.
% Hlp = ...
[Hlp, w] = freqz(blp, alp, nfft, 'whole', fs);
Hlp = fftshift(Hlp); % Center around 0 MHz
% TODO: Complex baseband frequency response. Hb(f) = Hlp(f)Hchan(f)
% Hb = ...
Hb = Hlp .* Hchan;
% TODO: Plot the magnitude response of Hb in dB.
figure;
plot(f, 20*log10(abs(Hb)));
axis([-fs/2 fs/2 -60 10]);
xlabel('Frequency (MHz)');
ylabel('10 log_{10}|H_b(f)|^2');
Confirm the PSD formula
The relationship between Sy and Sx is given as Sy = Sx|H_b(f)|^2
% TODO: Plot Sy(f) and Sx(f)|H_b(f)|^2 vs. f. plot both on the same
% graph. You should see they match except for very small signals < -60 dB.
Sy_theory = Sx .* abs(Hb).^2;
figure;
plot(f, 10*log10(Sy), 'b', f, 10*log10(Sy_theory), 'r--');
legend('Measured Sy', 'Sx|Hb|²');
xlabel('Frequency (MHz)');
ylabel('PSD (dB)');
Published with MATLAB® R2024a