0% found this document useful (0 votes)
175 views

Matlab Problems PDF

This document contains 9 MATLAB problems related to signal processing topics like filtering, modulation, and demodulation. The problems involve writing MATLAB code to simulate and analyze signals and systems. Some key tasks mentioned are convolving signals with rectangular windows, comparing spectrum results from rectangular and Gaussian windows, simulating AM/DSB/SSB modulation and demodulation, analyzing effects of filtering and modulation errors, and simulating mobile fading due to multipath signals.

Uploaded by

Man Dark
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
175 views

Matlab Problems PDF

This document contains 9 MATLAB problems related to signal processing topics like filtering, modulation, and demodulation. The problems involve writing MATLAB code to simulate and analyze signals and systems. Some key tasks mentioned are convolving signals with rectangular windows, comparing spectrum results from rectangular and Gaussian windows, simulating AM/DSB/SSB modulation and demodulation, analyzing effects of filtering and modulation errors, and simulating mobile fading due to multipath signals.

Uploaded by

Man Dark
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Chapter 2

MATLAB Problems

2.1 Real signals have finite time durations which are approximated by a finite time
window. Given the spectrum of x(t ) = cos 2π50t that has been created using a
sampling rate of 1000 Hz. Show how its spectrum is affected by convolving the
sinusoidal wave with a rectangular window of widths T / 2, T , 5T , and 10T .
How does the width of the rectangle affect the spectrum?

2.2 Repeat 2.1 using a gaussian window with σ = T / 2, T , 5T , and 10T . Which type
of window better represents the signal’s spectrum?

2.3 Simulate the system of Example 2.3-2 with f c = 1000 Hz.

2.4 Write a program to show the values of time delay(s) td such that
sin ( 2π f 0t ) is orthogonal to cos [ 2π f 0 (t − td ) ] . Then relate time delay to
distance. Let f 0 = 50.

2.5 Write a program to show that the terms of a Fourier series are orthogonal. As a
test case, use the first two terms of a square wave.

2.6 Write a program to plot the waveform and spectrum of a raised cosine pulse. Let
f = 1 and τ=0.5.

2.7 Write a program to show that the DFT for a gaussian pulse is also gaussian.

2.8 Write a program to plot the DFT of a single occurrence of a rectified sinusoidal
wave. Compare the values for the coefficients of the Fourier series of its periodic
version. What conclusions can you draw from this comparison?

2.9 Write a program to convolve two rectangular pulses of width τ . Then add to this
program to convolve four and then eight pulses. What would you expect the
convolution of an infinite number of pulses to converge to? How is the resultant
pulse width affected by the number of convolutions.

Given the following a system with input x(k ) = 2e − ( k − 40) + 4e − ( k − 60)


2 2
/10 /10
2.10 and
impulse response function h(k ) = e − ( k − 50) / 20 with k = 1:128. Determine the
2

output function y (k ) = x(k ) ∗ h(k ) using (a) the definition of discrete convolution
given by Eq. (7) of Sect. 2.6, and (b) a 128 point FFT.

1
Chapter 4
MATLAB Problems

4.1 Write a program to amplitude modulate a 1000 Hz carrier using 50%, and 100%
levels, and Ac = 10 . Use a single-tone message with f m1 = 100 and Am1 = 1.0. Plot
the time and frequency domain versions of your AM signal. How does the 50%
version differ from the 100%?

4.2 a. Repeat 4.1 except use DSB modulation.

b. Add a 6th order Butterworth BPF to your DSB signal to suppress the lower
sideband. Plot the time and frequency domain versions of your USSB
signal. Note: don't forget the negative frequencies. What conclusion(s)
can you draw from the results?

c. Repeat above step 4.2b, except use a 3rd order Butterworth filter.
Compare the amount of sideband suppression. How does the reduced
filtering affect the results?

d. Repeat above step 4.2b, except add a a second message tone


with f m 2 = 140 and Am 2 = 0.5. Compare the results with those of Prob.
4.2a. What conclusion(s) can you draw from this experiment?

4.3 Add the necessary software to Prob. 4.1 to create an envelope detector that will
demodulate the AM signal. Show that the detector output is the same as the
original message. For each stage of the envelope detector (rectifier, LPF, etc.)
plot the signal’s time and spectra.

4.4 Repeat 4.3 except create a product detector. Plot the signals for each stage.

4.5 Repeat Prob. 4.4, except use a product detector where the local oscillator has an
error of 2%. How is the detector’s output affected by the error?

4.6 Show that your product detector will also demodulate the two-tone USSB signal.

4.7 Repeat 4.3 except create an envelope detector using a nonlinear device with the
following input-output characteristic: vout = vin + vin2 You may use adders, scalars,
but not a multiplier.

4.8 Implement a SSB system using Weavers method. Demonstrate that it works
using the two tone message of Prob. 4.2d.

4.9 Show that an envelope detector is not suitable to demodulate a DSB signal. As a
test case, use a DSB with f c = 1 kHz and the two-tone message of Prob. 4.2d.

1
For comparison purposes, demodulate your DSB signal using both a product and
envelope detectors. What conclusions can you draw?

4.10 Design a DSB modulator using the nonlinear device of Prob. 4.7 and any
combination of adders, or filters, but not a multiplier. Show your design works by
using the two-tone message of Prob. 4.2b.

2
Chapter 7
MATLAB PROBLEMS

7.1. Develop the Matlab code to simulate an AM broadcast superhet receiver for the
specifications of Table 7.1-1. Evaluate its performance with respect to image
rejection. To improve computation speed, reduce all frequencies by a factor of
1000. Thus f IF = 455 kHz → 455 Hz, 540 < f c < 1700 Hz, and
995 < f LO < 2155 Hz, etc. Use a 1st order BPF for the IF strip with B = 10 Hz.
Have the input signal consist of a carrier with amplitude Ac = 1. Set the receiver
local oscillator frequency such that f LO = 1075 Hz and therefore the nominal value
of f c = 620 kHz. Let’s initially assume there is no filtering at the receiver’s front
end.
a. Sweep the AM signal’s carrier frequency from 500 to 3000 Hz and
determine the receiver response versus input frequency.
b. Add a 3rd order butterworth filter at the receiver’s front end with cutoff
frequency f 0 = f LO Hz. and then repeat the above step. How does the
front end LPF affect image response?

7.2 Repeat Prob 7.1 except for f IF = 2000 kHz . This means f LO = 2620 for
f c = 620 kHz. (a) Have a 1st order butterworth filter at the receiver’s front end
with f 0 = f LO , (b) Repeat part (a) with a 3rd order butterworth filter at the front
end. Compare and discuss your results of this problem and the results obtained
from Prob. 7.1. What other function is this receiver system performing?

7.3 Simulate the system of Fig. 7.2-6 to show that you can transmit two messages
over a single channel without interference if you use two orthogonal carrier
signals. For test purposes, use DSB signals at the same carrier frequency equal to
f c = 620 Hz, single tone message and the following parameters: Ac1 = Ac 2 = 1,
Am1 = 1, Am 2 = 0.5, f m1 = 10 Hz, and f m 2 = 7.5 Hz.

7.4 Repeat Prob. 7.3 except to show the effects of a 45 degree phase error in the
quadrature component. Comment on your results.

7.5 Simulate the DC receivers of Figs. 7.1-3 and 4 to show how each receiver
processes LSSB and USSB signals transmitted at the same carrier frequency.
Input two signals to the receiver, one a LSSB with a 10 Hz message at
f c = 1 kHz, and the second a USSB with a 20 Hz message at f c = 1 kHz. Show
that the receiver in Fig. 7.1-4 rejects the LSSB signal whereas the receiver in Fig.
7.1-3 will allow the two signals to interfere with each other.

7.6 Implement and simulate an PLL FM detector using the basic blocks shown in Fig.
7.3-2. Use the FM signal of MATLAB Prob. 5.1 to test your detector. Plot
several cycles of the message to indicate the how quickly the PLL achieves lock.
Chapter 3
MATLAB Problems

3.1 Write a program to determine the order of a Butterworth LPF needed to insure
that the bandwidth of an audio signal is -60 db down from its maximum at a
frequency of 20 kHz and has a half power frequency of 15 kHz. Assume that the
input signal is flat over 20 kHz.

3.2 Write a program to show how multipath causes fading with signals received on a
mobile receiver. Limit yourself to fading due to signal cancellation as modeled in
Fig. 3.2-9. Thus you may neglect path losses due to spherical dispersion,
absorption by the media, etc.. Assume the following: (a) the frequency is 1900
MHz, (b) the transmitter’s antenna is 100 feet high and radiates omni
directionally, (c) the receiver is 5 feet off the ground, (c) the linear distance
between the tower base and the receiver will vary between 1 to 5 kilometers, and
(c) the signal reflects halfway between the transmitter and receiver, thus the angle
between ground and tower and ground and receiver will vary as the receiver
moves away from the tower. Plot signal strength versus distance from the
transmitter. Hint: before writing code, make a sketch of your system and specify
how the multipath distances and time delays are affected was he receiver moves
away from the transmitter.

3.3 Given a single order RC LPF whose half power frequency is 20 kHz. At what
input frequency does the amplitude and phase distortion exceed 1%?

3.4 Write the code for a correlator that will recognize a single period 50 Hz sine wave
sampled at 500 Hz, and reject other sinusoidal waves. Plot the maximum value of
correlator output for inputs of 1 to 100 Hz.

3.5 Using adaptive cancellation, write a program that will eliminate 60 Hz


interference that has corrupted a 1000 Hz sine wave. As a benchmark, compare
your results if you used a single order band reject filter.

3.6 Determine the degree of adjacent channel rejection for a single order BPF used on
an AM broadcast radio. Assume the BPF’s center frequency is 990 kHz and the
interfering signals are occurring at 1000 and 1010 kHz and that all signals have
equal power. What would be the level of interference rejection if a third order
BPF were used.

3.7 Dynamic range. Consider a system with an input/output relationship of


y = T [ x] = tan −1 ( x) and an input of x(t ) = A1 cos 2π100t + A2 cos 2π400t with
with A1 > A2 . Determine the values of A1 and A2 whereby the system is 90%
linear. Plot output versus input for your values of A1 and A2 alongside a linear
plot to show where the output values deviate from the linear line. There may be
more than one solution.

1
Chapter 9
MATLAB Problems

9.1 Simulate the transmission of a single tone message in the presence of additive
white gaussian noise (AWGN) to show the effects of low pass filtering on the
signal’s power spectral density plot and the effects of the filter’s bandwidth on
( S / N )D .
(a) The system with a single tone sinusoidal input has the following parameters:
(i) Am = 1, and f m = 100,
(ii) 1st order LPF with W = 100 Hz,
(iii) coefficient of randn = 2.

Plot both the noisy signal and its power spectral density. You may have to
expand the amplitude scale to see the noise component. Then calculate a
precise value of signal-to-noise ratio (SNR) at the destination. You should
run several trials and get an average destination SNR.

(b) Repeat (a) except with W = 500 Hz, and then W = 1000 Hz. Comment on
how your results are affected by the LPF bandwidth.

9.2 Repeat Prob. 9.1 except use a 5th order LPF. Comment on to what degree the
order of the LPF affects the calculated value of ( S / N ) D . How significant is the
order with respect to ( S / N ) D ?

9.3 Repeat Prob. 9.1 except use a matched filter. Compare the results of the matched
filter against the results of Probs. 9.1 and 9.2.

t − 0.5 (t − 0.5)2 /100


9.4 Consider gaussian monocycle pulse x(t ) = e that has been
100
corrupted by AWGN such that x _ noisy (t ) = x(t ) + n(t ) and σ noise = 0.5 .

(a) Write a program to obtain estimate xˆ (t ) = h(t ) * x _ noisy (t ) using a first order
butterworth LPF with f 0 the half power frequency of x(t ). Plot
x(t ), x _ noisy (t ), and xˆ (t ).

(b) Repeat (a) using a matched filter.

(c) For both parts (a) and (b) calculate ( S / N ) D . You should do several trials to
obtain an average value of ( S / N ) D . Comment on your results.

Repeat Prob. 9.4 except with gaussian pulse x(t ) = e(t −1)
2
/100
9.5 .

1
9.6 An ad hoc method of removing noise from the output of an analytical
instrumentation system is the smoothing filter whereby the data is filtered using a
weighted average algorithm. One implementation is the processed data sample is
a weighted average of the original sample and eight adjacent data points, the
higher weight given to those points nearest to the sample of interest. The
smoothing operation is a form of interpolation.

Consider an instrumentation system where the observed data consists of the ideal
data sample plus noise or simply y (k ) = x(k ) + n(k ) . The weighted average
operation that estimates the ideal data point could be

1 3 5 7
xˆ (k ) = y (k − 4) + y (k − 3) + y (k − 2) + y (k − 1)
64 64 64 64
32
+ y (k )
64
7 5 3 1
+ y (k − 1) + y (k − 2) + y (k − 3) + y (k − 4)
64 64 64 64

Let y (k ) = 2e − ( k − 30) / 4 + n(k ) where n(k ) is gaussian noise with σ2 = 1


2

(a) Write a program to simulate the noisy signal and implement the above
smoothing filter to obtain estimate xˆ (k ) . Plot x(k ), y ( k ) and xˆ (k ). What
is the shape of the filter’s impulse response function and the
corresponding frequency response?

(b) Repeat (a) except instead of the estimate based on the weighted average of
the adjacent signals, use ordinary averaging where
1 4
ˆx(k ) = ∑ y (k + i )
9 i =−4

(c) Repeat (a) except use a matched filter to obtain estimate xˆ (k ) .

(d) Comment on our results and state any conclusions.

9.7 This problem is meant to illustrate what it means for noise to be “white”. You
have learned that ideal white noise is a theoretical signal that has equal power at
all frequencies – a flat spectrum for frequencies on (-∞: ∞), and a corresponding
autocorrelation of δ(τ). Of course, this signal would have infinite power. What is
white noise other than a mathematical abstraction?

Another way to describe white noise is to say that each of its samples is
statistically independent. For theoretical white noise, this holds no matter how
fast the samples are taken. However, in digital systems, we represent signals as
series of samples that have been taken at a particular rate, the sampling frequency
f s . This is the highest frequency known to the system. If a signal’s power rolls

2
off at a frequency higher than f s , it can still be considered white for practical
analysis of the system.

In this problem we will investigate the effect of sampling frequency on the power
spectrum and the autocorrelation of a signal. You should see that as the signal is
sampled more slowly than its correlation time – the lag between samples that are
statistically dependent – it approaches the ideal of white noise.

(a) Create a random signal, then upsample it so that it has some known
amount of correlation with itself. Plot the signal, its power spectral
density (PSD), and its autocorrelation function (ACF), taking care to label
all the axes.

(b) Now downsample your signal to a rate below your original upsampled
rate. The signal should now appear to be “white,” based on its PSD and
ACF. Plot the signal, its PSD, and its ACF. Take care to label the axes
properly.

(c) Compare the two sets of plots and explain how the same signal can result
in such different spectra.

9.8 Create three independent random signals, called A, B, and C. Next, create the
signals x, y, and z as follows:
x = A + B;
y = B + C;
z = 5 − C;

Which of the signals x, y, and z, taken pairwise, are statistically independent?


Dependent? Plot the cross-correlation function magnitudes of each pair to back
up your answers. Size the axes on each plot the same so that the plots are
comparable.

9.9 Create a series of 100 random numbers called z1 , and make a copy of it called z2 .
Next, add a new series of 50 random numbers to the beginning of z1.

At what lag would you expect the peak of the cross-correlation between z1 and
z2 ? Compute the cross-correlation and indicate where its peak(s) lie.

9.10 Clipping a signal (for example, “railing out” an amplifier) can be considered a
type of noise, albeit a very predictable type of noise. In this problem, we will see
that predictable and periodic noise are often worse than random noise when one is
looking for a signal’s frequency content.

3
Create an oversampled signal which is the sum of two sinusoids, as shown:

fs = 10; % Hz
t = [0:1/fs:500]; % sec
x = sin(2*pi*t) + 0.6*sin(0.5*2*pi*t);

(a) Where do you expect the peak(s) of the frequency spectrum of x?


Compute and plot the power spectral density of x.

(b) Now, strongly clip this data to +/- 0.5 volts:

y = x; (x > 0.4) = 0.4; y(x < -0.4) = -0.4;

Do you expect to see the same PSD for y as for x? If different, how?
Plot both x and y versus time, then plot the PSD for y. Explain the
differences in the PSDs for x and y.

(c) Now modify x by adding random noise at the same amplitude level. This
is called ‘dithering’ :

x_dithered = randn(1,N) + x;

Plot the new x versus time. Where do you expect the frequency peaks to
be? Plot the PSD for the new x.

(c) Finally, strongly clip the randomized x signal as before. Plot the new y
versus time as well as the PSD for the new y. Are the peaks in the correct
place(s)? Why do you think this works? (Hint: look up the concept of
‘dithering’.)

4
Chapter 10
MATLAB Problems

10.1 Simulate the transmission of a single tone message in the presence of additive
white gaussian noise (AWGN) to show the effects on low pass and band pass
filtering on the signal’s power spectral density plot.

(a) Transmitt a single tone baseband signal with parameters of


(i) Am = 1, and f m = 200,
(ii) 3rd order LPF with W = 500 Hz,
(iii) ( S / N ) D ≈ 100 − 200 dB.

Plot both the power spectral density of the noisy signal. You may have to
expand the amplitude scale to see the noise component. Calculate a
precise value of signal-to-noise ratio.

(b) Repeat part (a) except simulate an AM signal containing the message in
Part (a). Use the parameters of

(i) Ac = 1, and f c = 1500, μ =1, Am = 1, f m = 200


(ii) 3rd order BPF with center frequency =1500 Hz, and BT = 1000 Hz
(iii) Enough additive noise to see it in a power spectral density plot.

Plot the power spectral density of the modulated signal with and without band
pass filtering. Again, you may have to expand the amplitude scale to see the
noise component.

10.2 Write a program to simulate the performance of envelope and product detectors to
demodulate a 100 % modulated AM signal with a single tone message. Use the
following parameters for your transmitter and receiver:
f c = 2000 Hz, f m = 200 Hz, Ac = 1, Am = 1, μ = 1, 3rd order LPF, and W =500 Hz.
Try a various ( S / N ) levels. Once you get a specific level of ( S / N ) to where
the product detector’s output is somewhat clear as compared to the envelope
detector’s, then do 20 runs of your simulation to average out the signal
waveforms. Plot the detectors’ outputs. State any observations or conclusions of
your results.

10.3. Using the message and filter parameters in Prob. 10.2, compare the ( S / N ) D
performance of AM versus DSB using product detection. Make the necessary
plots of your signals.

10.4 Repeat Prob. 10.3 except have the product detector demodulate a DSB signal and
the envelope detector demodulate an AM signal. Consider averaging the detector
outputs.

1
10.5 Simulate an AM system using various values of γ to show threshold effects and
verify Eq. (15b) of Sect. 10.2 for (a) an envelope detector, (b) verify the statement
on page 453 that there is no threshold effect with the product detector.

10.6 Implement and simulate an FM system with a slope detector, single tone message
and a received signal that has been corrupted by AWGN. Consider the following:

(a) Test your system to see the threshold effect and signal quality.
(b) Determine the degree in which Eq. (19) of Sect. 10.3 establishes the
threshold point at which further increases in D no longer improve the
signal quality.

Output the appropriate plots and make any appropriate observations and
conclusions.

2
Chapter 5
MATLAB Problems

5.1 Generate and plot a WBFM signal and its spectra with single tone message and
the following specifications: Ac = 10, f c = 1200 Hz, β = 5, f m = 60 Hz,
and f Δ = 150 Hz. Is the resulting spectra similar to what is shown in Figs. 5.1-5
and 5.1-1?

5.2 Repeat Prob. 5.1 for NBFM with Ac = 10, f c = 1200 Hz, β = 0.2, f m = 60 Hz, and
f Δ = 12 Hz. How does this differ from an AM signal? If filtering or other
operations were applied to the signal, what is needed to insure that we still have a
NBFM signal?

5.3 Generate an indirect FM signal using the exciter of Prob. 5.2 and a clipper to
generate odd multiples of f c = 1200 Hz. Plot the magnitude of the clipper output
and see if the spectral components match that of Table 5.1-2.

5.4 Repeat Prob. 5.3 using the same parameters except have Am = 2 , but keep
β = 0.2 . What observations and conclusions can you draw from your results?

5.5 Add a heterodyne unity to the FM exciter of Prob. 5.2 to cause the carrier
frequency to be 6000 Hz. Does changing the carrier frequency via heterodyning
affect BT ?

5.6 Design and simulate a slope detector to detect the FM signal of Prob. 5.1. Show
your detector works by plotting the time and frequency domains of the
demodulated output. Use a Butterworth or similar realizable filter to perform the
derivative function. However, you may want to initially use a derivative function
to get things working. Be sure to plot the time and frequency versions of the
signal at the output of the (a) generator, (b) derivative function, (c) rectifier, (d)
LPF, and (e) envelope detector output.

5.7 Repeat 5.4 except insert a limiter before the derivative function.

5.8 Generate two carrier frequencies, one with amplitude of 10 and frequency of 1
kHz and the other at 1.1 kHz with amplitude of 1. Plot their sum in both the
time and frequency domain. Input the sum into an envelope detector and plot the
output. Do you get the result predicted in Eq. (4) of Sect. 5.4?

5.9 Consider the effects of interference on a crowded nighttime broadcast AM band


where stations are transmitting on almost every 10 kHz frequency slot. To speed
up computation, we will scale the frequencies by a factor of 1000 and we will use
just two stations. Use the following parameters for stations #1 and #2:
f c1 = 990 Hz, f c 2 = 1000, μ1 = μ 2 = 1, Ac1 = Ac 2 = 10, f m1 = 1 Hz, Am1 = 1,

1
f m 2 = 3 Hz, and Am 2 = 1. Plot the receiver input and output and describe
comment on your results.

5.10 Do Prob. 5.9 except use DSB and a synchronous detector. Compare your results
with those of Prob. 5.9 and state any conclusions.

5.11 Let’s consider the effects of multipath interference with AM and the envelope
detector where the envelope detector receives the direct and multipath versions.
The direct signal has the following parameters: Ac1 = 10, f c1 = 990 Hz, μ1 = 1,
and f m1 = 1 . The multipath interference has the same parameters as the direct
signal, except it’s phase is uniformly distributed between 0 and −π radians.
Do several trials and discuss your results.

5.12 Repeat 5.11 except with a DSB signal and a synchronous detector.

You might also like