rectpuls(t)
tripuls(0.5*t)
stepfun(t, 0)
sinc(t)
heaviside
also implements the unit
step function but takes an amplitude of 0.5 at the origin instead of 1.
You can receive help on a particular Matlab command by typing
help stepfunYou can also use the
lookfor
command to find a Matlab
command for a given task.
plotspec
.
The plotspec
function takes the time-domain signal and the
sampling time as arguments, and plots the time-domain waveform and
the magnitude of its Fourier transform.
The plotspec
command uses the fast Fourier transform (FFT)
of the sampled signal values to compute the frequency response.
The FFT algorithm takes a vector of N time-domain samples and
returns a vector of N frequency-domain samples.
Matlab has its own plotspec
function that takes
three arguments and plots a time-frequency signal representation
called a spectrogram.
This is a very different function from the plotspec
function
in the JSK textbook.
To access the functions provided by the Matlab files that accompany
Software Receiver Design textbook, the directory containing the
Matlab files would need to placed first on the Matlab search path.
Please see the Matlab hints for
more information.
The two-tap discrete-time averaging filter, with input x[n] and output y[n], is described by
y[n] = 1/2 x[n] + 1/2 x[n-1]Two taps means two terms. To compute the current output y[n], we average the current input x[n] and the previous input x[n-1].
y[n] = (x[n] + x[n-1]) / 2We can alternately use the following unnormalized version with reduced complexity:
y[n] = x[n] + x[n-1]
n ---| \ y[n] = | x[m] / ---| m = 0The above equation is not terribly efficient as the amount of memory to store previous input values grows without bound as n increases. A computationally efficient version of the equation is given below:
plotspec
is defined by the Matlab
file plotspec.m that comes with the JSK book.
The plotspec
command will accept the vector of
amplitude values in the time domain and a sampling period.
It will plot the signal in the continuous-time domain (top plot)
and the signal's magnitude (bottom plot).
The time-domain plot assumes that the time-domain signal starts
at t = 0.
In this problem, the signals start at t = -4.
You could either correct the printout manually, or create your
own plotspec function called myplotspec that takes a third argument
of the starting time, or you could generate your own plots.
The rectangular pulse rect(t) has an amplitude of 1 over -1/2 ≤ t < 1/2.
Problem 1.2(a) involves a rectangular pulse that has amplitude of 1 from t=-4 (inclusive) and t=4 (not inclusive), i.e. -4 ≤ t < 4. The rectangular pulse can be also be written as
rect(t/8) = u(t+4) - u(t-4)If u(0) = 1, then rect(t/8) would take a value of 1 over the interval -4 ≤ t < 4.
Problem 1.2(c) involves the continuous-time signal
Please see the hint below for problems 1.2 and 1.3.
Each problem asks you to give a sampling rate fs for each continuous-time signal and why you chose that sampling rate.
The Sampling Theorem states to choose fs > 2 fmax, where fmax is the maximum frequency of the continuous-time signal x(t), so that it is possible to reconstruct the continuous-time signal x(t) from its samples (see lecture slide 4-8).
In practice, sampling at a rate that is much higher than 2 fmax is common. To determine the sampling rate, you'll need to estimate fmax for each signal.
Here are three ways to estimate fmax:
plotspec
to plot the magnitude spectrum and
pick larger and larger sampling rates until the shape of the
spectrum and its associated fmax value
do not change.
Here's example code using plotspec in the trial-and-error approach:
fs = 0.1; Ts = 1/fs; t = -20 : Ts : 20; x = exp(-t.^2); plotspec(x, Ts);
One could then increase the sampling rate fs by a factor of 10 each time until the shape of the magnitude spectrum stays the same (to within a scaling factor). Note that increasing the sampling rate means more samples will be taken per second, and hence the DC component may increase with increasing sampling rate.
One can automate the power bandwidth method to estimate fmax. The following Matlab commands may be useful.
Example:
x=[1 4 6 10]; find(x>5);This returns the indices for values in vector x that are greater than 5, i.e. indices 3 and 4. The command
min(find(x>5))returns the least of these indices which is 3.