Signal Implementation With MATLAB No Solution - MuayEdit031339923064
Signal Implementation With MATLAB No Solution - MuayEdit031339923064
We use a set of sample values from sampling of continuous-time (CT) signal to represent the
continuous time signal in a mathematical form. For example
>> t = [-5:0.001:5]; % Set the time from -5 to 5
% with a sampling
% rate of 0.001s
>> x = 5*sin(2*pi*t1)
% compute function x1
% plot x(t)
>> plot(t,x); % plot a CT signal
>> grid on; % turn on the grid
>> xlabel(‘time (t)’); % Label the x-axis as time
>> ylabel(‘5sin(2\pi t)’); % Label the y-axis
>> title(‘Part (a)’); % Insert the title
First of all, the time value for which x (t) is to be plotted stored as element vector t. Second,
create a vector with elements corresponding time values by the expression 5*sin(2*pi*t) .
Third, by the command plot(t,x) , x is plotted versus t. The resulting plot of x(t) is shown in
the figure. Two important things to note that, in generating a MATLAB plot of a continuous-
time signal, first, to plot a continuous-time signal we use the command plot(t,x), and second ,
the increment in time step must be sufficiently small to yield a smooth plot.
Problem 1A. 1
Generate and sketch in the same figure each of the following CT signals using MATLAB. Do
not use the “for” loops in your code.
In each case, the horizontal axis t used to sketch the CT should extend only for the range
over which the three signals are defined.
(a) x1(t ) = 5 sin(2πt+5 ) cos(πt − 8) for −5 ≤ t ≤ 5;
(b) x2(t ) = 5e−0.2t sin (2πt-3 ) for −10 ≤ t ≤ 10;
(c) x3(t ) = e(j4π−0.5)t u(t+2 ) for 5 ≤ t ≤ 15.
In this section, on the other hand, if a signal is defined only at discrete values of time, it is
called a discrete-time (DT) signal. We use as a set of sample values from sampling of continuous-
time (CT) signal to represent the continuous time signal in a mathematical form.
In our notation, a CT signal is denoted by x(t ) with regular parenthesis, and a DT signal is
denoted with square parenthesis ,x[k]. An important things to note that we use the command
stem(k,x) to plot a discrete-time signal.
Elementary signals
Unlike the CT unit impulse function, the DT impulse function has no ambiguity in its
definition; it is well defined for all values of k.
o Sinusoidal function
The DT sinusoid is defined as follows:
,
where is the DT angular frequency. A CT sinusoidal signal x(t ) =sin( t + θ) is
always periodic, whereas its DT counterpart x[k] = sin( k +θ) is not necessarily
periodic. The DT sinusoidal signal is periodic only if the fraction /2π is a rational
number.
o DT exponential function
The DT complex exponential function with radian frequency is defined as follows:
(1.39)
Case 1 Imaginary component is zero ( = 0). The signal takes the following form:
,
Case 2 Real component is zero (σ = 0). The DT exponential function takes the
following form:
Recall that a complex-valued exponential is periodic if /2π is a rational number. An
alternative representation of the DT complex exponential function
(c ,0 ≤ k ≤ 50.
at all time t and for some positive constant T0. The smallest positive value of T0 that satisfies
the periodicity condition, Eq. (1.3), is referred to as the fundamental period of x(t ).
at all time k and for some positive constant K0. The smallest positive value of that satisfies
the periodicity condition, Eq. (1.4), is referred to as the fundamental period of x[k]. A signal
that is not periodic is called an aperiodic or non-periodic signal.
The reciprocal of the fundamental period of a signal is called the fundamental frequency.
Mathematically, the fundamental frequency is expressed as follows
where and are, respectively, the fundamental periods of the CT and DT signals. The
frequency of a signal provides useful information regarding how fast the signal changes its
amplitude. The unit of frequency is cycles per second(c/s) or hertz (Hz).
Sometimes, we also use radians per second as a unit of frequency. Since there are 2π radians
(or 360◦) in one cycle, a frequency of hertz is equivalent to 2π radians per second. If
radians per second is used as a unit of frequency, the frequency is referred to as the angular
frequency and is given by
, for CT signals, or for DT signals
The term rational number is defined as a fraction of two integers. Given that the DT
sinusoidal sequence is periodic, its fundamental period is evaluated
from the relationship
As
This can be extended to include DT complex exponential signals. Collectively, we state the
following.
(1) The fundamental period of a sinusoidal signal that is evaluated by
with m set to the smallest integer that results in an integer value for .
(2) A complex exponential θ to be periodic
More over we can represent a periodic signal with a sum of single-period models each of
which is shifted to be adjacent to another. That is
Where the model of one period signal starting at the arbitrary time
Where
Problem 1B. 1
The following term is given for the impulse sequence:
The total length of the sequence is MP, with P the period. Generate a impulse sequence s(k )
with the period P = 10 and a total length of 40 values. The start index shall be k=0 and the
scaling factor Ai shall be identical 1.
Problem 1B. 2
The following MATLAB Code generates a sequence x:
x=[0;1;1;0;1;0]*ones(1,7); x=x(:);
Display x with the help of the MATLAB function stem(k,x) and create a a sum of single-
period models corresponding to the equation for the signal x .
, −25 ≤ k ≤ 25
, −25 ≤ k ≤ 25
, 0 ≤ k ≤ 55
, 0 ≤ k ≤ 55
Question:
- Report a simple equation for x2(k) without using trigonometrical functions!
- Why are x3(k) and x4(k) not periodical sequences?
CT signals
DT sequences
The total energy of a CT signal is its energy calculated over the interval t = [−∞,∞]. Likewise,
the total energy of a DT signal is its energy calculated over the range k = [−∞,∞]. The
expressions for the total energy are therefore given by the following:
CT signals
DT sequences
Since power is defined as energy per unit time, the average power of a CT signal x(t )over the
interval t = (−∞,∞) and of a DT signal x[k] over the range k = [−∞,∞] are expressed as
follows:
CT signals
DT sequences
Both equations are simplified considerably for periodic signals. Since a periodic signal
repeats itself, the average power is calculated from one period of the signal as follows:
CT signals
DT sequences
The symbols and are, respectively, the fundamental periods of the CT signal x(t ) and
the DT signal x[k]. To illustrate this mathematically, we introduce the notation to imply
that the integration is performed over a complete period and is independent of the lower
limit. Likewise, while computing the average power of a DT signal x[k], the upper and lower
limits of the summation can take any values as long as the duration of summation equals one
fundamental period .
A signal x(t ), or x[k], is called an energy signal if the total energy has a non-zero
finite value, 0 < < ∞. On the other hand, a signal is called a power signal if it has non-zero
finite power, i.e. 0 < < ∞. Note that a signal cannot be both energy and a power signal
simultaneously. The energy signals have zero average power whereas the power signals have
infinite total energy.
Problem 1C. 1
Determine if the DT sequence g[k] = 3 cos(πk/10) is a power or an energy signal and also
write an m-file for calculation.
D. Even and odd signals.
A CT signal (t ) is said to be an even signal if
]
The even signal property, Eq. (1.16) for CT signals or Eq. (1.18) for DT signals, implies that
an even signal is symmetric about the vertical axis (t = 0). Likewise, the odd signal property,
Eq. (1.17) for CT signals or Eq. (1.19) for DT signals, implies that an odd signal is anti-
symmetric about the vertical axis (t = 0).
Such signals are classified in the “neither odd nor even” category. Neither odd nor even
signals can be expressed as a sum of even and odd signals as follows:
Fig. 1.7. (a) The CT signal x(t ) (b) Even component of x(t ). (c) Odd component of x(t ).
Problem 1D. 1
Determine if the following DT signals are even, odd, or neither even nor odd. In the latter
case, evaluate and sketch the even and odd components of the DT signals:
(i) x1[k] = sin(4k) + cos(2π/k3);
(ii) x2[k] = sin(πk/3000) + cos(2πk/3);
(iii) x3[k] =exp(j(7πk/4)) + cos(4πk/7 + π);
(iv) x4[k] = sin(3πk/8) cos(63πk/64);
(v) x5[k] =
2. Signal operations
An important concept in signal and system analysis is the transformation of a signal.
In this section, we consider three elementary transformations that are performed on a signal
in the time domain. The transformations that we consider are time shifting, time scaling, and
time inversion.
Time shifting
The time-shifting operation delays or advances forward the input signal in time.
Consider a CT signal φ(t ) obtained by shifting another signal x(t) by T time units. The time-
shifted signal φ(t ) is expressed as follows:
If T < 0 , the signal is said to be delayed in time. To obtain the time-delayed signal φ(t ) ,the
origin of the signal x(t) is shifted towards the right-hand side by duration T along the t-axis.
On the other hand, if m > 0, the signal is advanced forward in time. The time-advanced signal
φ(t ) is obtained by shifting x(t) towards the left-hand side by duration T along the t-axis.
If m < 0, the signal is said to be delayed in time. To obtain the time-delayed signal φ[k], the
origin of the signal x[k] is shifted towards the right-hand side along the k-axis by m time
units.
On the other hand, if m > 0, the signal is advanced forward in time. The time-advanced
signal φ[k] is obtained by shifting x[k] towards the left-hand side along the k-axis by m time
units.
Time scaling
The time-scaling operation compresses or expands the input signal in the time
domain. A CT signal x(t ) scaled by a factor c in the time domain is denoted by x(ct). If c > 1 ,
the signal is compressed by a factor of c. On the other hand, if 0 < c < 1 the signal is
expanded.
A CT signal x(t ) can be scaled to x(ct) for any value of c. For the DTFT, however, the
time-scaling factor c is limited to integer values. We discuss the time scaling of the DT
sequence in the following.
(i) Decimation
If a sequence x[k] is compressed by a factor c, some data samples of x[k] are
lost. Compression (referred to as decimation for DT sequences) is, therefore, an
irreversible process in the DT domain as the original sequence x[k] cannot be
recovered precisely from the decimated sequence y[k].
(ii) Interpolation
In the DT domain, expansion (also referred to as interpolation) is defined as
follows:
=
Time inversion
The time inversion (also known as time reversal or reflection) operation reflects the
input signal about the vertical axis (t = 0). When a CT signal x(t ) is time reversed, the
inverted signal is denoted by x(−t ). Likewise, when a DT signal x[k] is time-reversed, the
inverted signal is denoted by x[−k].
Problem 2.1
Write a MATLAB function mydecimate with the following format:
In other words, mydecimate accepts an input signal x[k] and produces the signal y[k] =
x[kM].
Problem 2.2
Repeat the last problem for the transformation y[k] = x[k/N]. In other words, write a
MATLAB function myinterpolate with the following format:
Problem 2.3
3. Classification of systems
We classified the systems based on the following definitions.
An important subset of systems is described by those that are both linear and time-invariant
(LTI).
1. An LTID system will be memoryless if and only if its impulse response h[k] = 0 for k
0.
2. An LTID system will be causal if and only if its impulse response h[k] = 0 for k < 0.
3. The impulse response h[k] of a (BIBO) stable LTID system is absolutely summable,
i.e.
4. An LTID system will be invertible if there exists another LTID system with impulse
response hi[k] such that h[k] ∗ hi[k] = δ[k]. The system with the impulse response hi[k]
is the inverse system.
Problem 3
Is the following system linear? time-variant systems?
we have so far presented two approaches to calculate the output response of an LTI
system: the differential equation method and the convolution method. Both methods can be
implemented using MATLAB. However, the convolution method is more convenient for
MATLAB implementation in the discrete-time domain.
Now consider the shifted impulse signal to the same system as shown in
figure below.
The output will also be shifted because we are considering only linear systems.
Therefore, will produce h[n-m].
We have also seen that any discrete signal can be represented as the sum of weighted
shifted impulses (samples). We have seen that the signal x[n] can be represented as
Note that each x[m] is a sample and a constant. Also, if x[m] is multiplied by and
applied to the discrete linear time-invariant system, the output will be as
figure below
Now let us say that we were to add all the shifted weighted samples
and present this as input to the same system. The output in this case is
or
∗
The above equation is the convolution equation that, given x[n], the input to a discrete
system, and h[n], the impulse response, will give you the output y[n].This also tells you that,
given h[n] for any system, you can find y[n]for any input x[n].
We can use MATLAB to compute y[n] for any input x[n] by convolution two
sequences x[n] and h[n] with MATLAB function conv(x,h).
Problem 4.1
2.
3.
Differential equations
In this section, we present the method for constant-coefficient differential equations
with initial conditions. MATLAB provides several M-files for solving differential equations
with known initial conditions. The list includes ode23, ode45, ode113, de15s,
ode23s, ode23t, and ode23tb. Each of these functions uses a finite-difference-based
scheme for discretizing a CT differential equation and iterates the resulting DT finite-
difference equation for the solution.
Example 1
Compute the solution y(t ) for an equation produced below for convenience:
+ 4y(t ) = 2 cos(2t )u(t ),
with initial condition y(0) = 2 for 0 ≤ t ≤ 15. Compare the computed solution with the
analytical solution.
Solution
The first step towards solving the equation is to create an M-file containing the differential
equation. We implement a version of above equation given by
+ 4y(t ) = 2 cos(2t )u(t ),
where the derivative dy/dt is the output of the M-file based on the input y and time t . Calling
the M-file myfunc1, the format for the M-file is as follows:
The above function is saved in a file named myfunc1.m and placed in a directory included
within the defined paths of the MATLAB environment. To solve the differential equation
defined in myfunc1 over the interval 0 ≤ t ≤ 15, we invoke ode23 after initializing the
input parameters in an M-file as shown:
The final plot for MATLAB calculation is shown in the figure below.
Zero-state response of the system The zero-state response is calculated by solving the
difference equation with a zero initial condition, y(0−) = 0. The homogeneous component of
the zero-state response of the difference equation is similar to the zero input response and is
given by
y(h)zs (t ) = Ce−4t ,
where C is a constant. The particular component of the zero-state response of the difference
equation for input x(t ) = sin(2t ) is of the following form:
y(p)zs (t ) = K1 cos(2t ) + K2 sin(2t ).
Substituting the particular component in difference equation gives K1 = 0.4 and K2 = 0.2.
The overall zero-state response of the system is as follows:
zero state response yzs(t ) = Ce−4t + 0.2 sin(2t ) + 0.4 cos(2t ),
with zero initial condition, i.e. yzs(t ) = 0. Substituting the initial condition in the zero-state
response yields C = −0.4. The total response of the system is the sum of the zero-input and
zero-state responses and is given by
y(t ) = 1.6e−4t + 0.2 sin(2t ) + 0.4 cos(2t ).
States as the total response of a LTIC system modeled with a first-order, constant-coefficient,
linear differential equation.
Difference equations
Which models the relationship between the input sequence x[k] and the output response y[k]
of an LTID system? The ancillary conditions y[−1], y[−2], . . . ,y[−n] are also specified. To
solve the difference equation, MATLAB provides a built-in function filter with the
syntax
>> [y] = filter(B,A,X,Zi);
In terms of the difference equation the input variables B and A are defined as follows:
A = [1, , . . . , ] and B = [ , ,..., ]
While X is the vector containing the values of the input sequence and Zi denotes the initial
conditions of the delays used to implement the difference equation. The initial conditions
used by the filter function are not the past values of the output y[k] but a modified
version of these values. The initial conditions used byMATLAB can be obtained by using
another built-in function, filtic. The calling syntax for the filtic function is as
follows:
>> [Zi] = filtic(B,A,yinitial);
For an n-order difference equation, the input variable yinitial is set to
>> yinitial = [y[−1], y[−2], . . . , y[−n]] ;
Example 2
The DT sequence x[k] = 2ku[k] is applied at the input of an LTID system described by the
following difference equation:
y[k + 1] − 0.4 y[k] = x[k],
with the ancillary condition y[−1] = 4. Compute the output response y[k] of the LTID system
for 0 ≤ k ≤ 50 using MATLAB.
Solution
The MATLAB code used to solve the difference equation is listed below. The explanation
follows each instruction in the form of comments.
The output response is stored in the vector Y. Printing the first six values of the output
response yields
Additional values of the output sequence for k > 5 can be similarly evaluated from further
iterations with respect to k.
Problem 4.2
Plot the output response y(t) from MATLAB solution in Example 1 compared with the output
response y(t) from analytical solving.
From the result of analytic solution solved Equation + 4y(t ) = 2 cos(2t )u(t ) ,we have
y(t ) = 1.6e−4t + 0.2 sin(2t ) + 0.4 cos(2t ).
Problem 4.3
The DT sequence x[k] = 0.5ku[k] is applied at the input of an LTID system described by the
following second-order difference equation:
y[k + 2] + y[k + 1] + 0.25y[k] = x[k + 2],
with ancillary conditions y[−1] = 1 and y[−2] = −2. Compute the output response y[k] of the
LTID system for 0 ≤ k ≤ 50 using MATLAB.
Problem 4.4
Linear difference equations are describe in MATLAB by two vectors a and b including in the
filter coefficients an and bm . The coefficient a0 is usually chosen to be 1.
and
where the exponential CTFS coefficients Dn are calculated using the following expression:
The plot of the magnitude |Dn| of the exponential CTFS coefficients versus the coefficient
number n is referred to as the magnitude spectrum, while the plot of the phase <Dn of the
exponential CTFS coefficients versus the coefficient number n is referred to as the phase
spectrum of the periodic signal x(t ).
Calculating the output response y(t) of an LTIC system to a periodic input x(t ). In
such cases, the output y(t) is given by
Where the transfer function is obtained from the impulse response h(t) of the LTIC
system as follows:
The above expression also defines the continuous-time Fourier transform (CTFT) for
aperiodic signals, which is covered in depth in next section.
Using MATLAB script, ictfs.m, to calculate the output response y(t) of an LTIC system
to a periodic input x(t ).
o First, we have to decide representations of CTFS weather it is the trigonometric or
exponential CTFS.
o Second, find input parameters such as - a0,an,and bn - for the trigonometric
representations of CTFS.
The coefficients are calculated using the following formulas:
and
For the exponential representations of CTFS ,we have to find input parameter,En
calculated using the following formula:
for n=1:no_coeff
x = x + an(n).*cos(n*w0*t) + bn(n).*sin(n*w0*t) ;
end
N = (no_coeff-1)/2;
no_iter =min(4000,N); % this limits the computational complexity
x = dna0(N+1)*ones(1,length(t)) ;
for n=1:no_iter
x1 = dna0(N+1+n).*exp(j*n*w0*t);
x2 = dna0(N+1-n).*exp(-j*n*w0*t);
x = x + x1 + x2 ;
end
else
end
Problem 5.1
A periodic signal is represented by the following CTFS:
(i) From the CTFS representation, determine the fundamental period T0 of x(t ).
(ii) Comment on the symmetry properties of x(t ).
(iii) Plot the function to verify if your answers to (i) and (ii) are correct .The function,
reconstructed using the first 1000 CTFS coefficients, is plotted for −1 ≤ t ≤ 1.
Hint !
o Fundamental frequency is the lowest frequency in a harmonic series.
o To plot the time interval ,−1 ≤ t ≤ 1, for the first 1000 CTFS coefficients ,we define
>> t = -1:0.001:1 ;
o Compare the equation
to .
nterms = 1000 ;
w0 = 4*pi ;
t = -1:0.001:1 ;
% x(t ) is an odd function, then a0 = an = 0 for all n.
a0=0 ;
% Initializing coefficients an as a vector
an = zeros(1,nterms) ;
Problem 5.2
Calculate the exponential Fourier series of the signal x(t ) shown in the figure.
Problem 5.3
Calculate the exponential CTFS coefficients of the output y(t ) if the square wave x(t )
illustrated in a figure below
∞ ∞
is applied as the input to an LTIC system with impulse response
h(t ) = exp(−2t )u(t ).
The transfer function of the LTIC is given by
The function, reconstructed using the first 4000 CTFS coefficients, is plotted for −15≤ t ≤15.
Hint!
% initializing CTFS parameters
nterms = 4000 ;
w0 = 1 ;
t = -15:0.01:15 ;
Step 1 Sampling In order to manipulate the CT signals on a digital computer, the CT signals
must be discretized. This is normally achieved through a process called sampling. In reality,
sampling is followed by quantization, but because of the high resolution supported by
MATLAB, we can neglect quantization without any appreciable loss of accuracy, at least for
our purposes here. Sampling converts a CT signal x(t ) into an equivalent DT signal x[k]. To
prevent any loss of information and for x[k] to be an exact representation of x(t ), the
sampling rate ωs must be greater than at least twice the maximum frequency ωmax present in
the signal x(t ), i.e.
Hence, the maximum frequency in x(t ) is given by ωmax = 10π radians/s. Based on the
Nyquist criterion, the lower bound for the sampling rate is given by
We choose a sampling rate that is 20 times the Nyquist rate, i.e. ωs = 400π radians/s. The
sampling interval Ts is given by
Selecting a time interval from −1 to 1 second to plot the sinusoidal wave, the number N of
samples in x[k] is 401. The MATLAB command that computes x[k] is therefore given by
There are two differences between y (output of the fft function) and the CTFT pair,
By looking at the peak value of the magnitude spectrum |y|, we note that the magnitude is not
given by 4π as the CTFT pair suggests. Also, the x-axis represents the number of points
instead of the appropriate frequency range ω. In steps (3) and (4), we compensate for these
differences without going into the details of why the differences occur.
The subplot of the CTFT is plotted in figure (d). By inspection, it is confirmed that it does
correspond to the CTFT pair. The phase spectrum of the CTFT can be plotted using the angle
function. For our example, the MATLAB command to plot the angle is given by
The phase spectrum of the CTFT can be plotted using the angle function. For our example,
the MATLAB command to plot the angle is given by
> subplot(2,2,4); plot(w,angle(z)); % phase spectrum
The above command replaces the magnitude spectrum in subplot(2,2,4)by the phase
spectrum. For the given signal, x(t ) = 4 cos(10πt ), the phase spectrum is zero for all
frequencies ω. The MATLAB code for calculating the CTFT of a cosine wave is provided
below in a function called myctft.
function [w,z] = myctft
% MYCTFT: computes CTFT of 4*cos(10*pi*t)
% Usage: [w,z] = myctft
% plots
subplot(211); plot(t,x) % CT plot of cos(w0*t)
subplot(212); plot(w,abs(z)) % CTFT plot of cos(w0*t)
% end
To calculate the inverse CTFT, we replace the function fft with ifft and reverse the
order of the instructions. The MATLAB code to compute the inverse CTFT is provided in a
second function called myinvctft:
function [t,x] = myinvctft(w,z)
% MYINVCTFT: computes inverse CTFT of y known at
% frequencies w
% Usage: [t,x] = myinvctft(w,z)
% plots
subplot(2,1,1); plot(w,abs(z)) % CTFT plot of cos(w0*t)
subplot(2,1,2); plot(t,real(x)) % CT plot of cos(w0*t)
% end
Problem 6.1
As the MATLAB code for computing the inverse CTFT is provided in a second function
called myinvctft. Use this function to show that the graphical generated from right hand
side is the inverse fourier transform of the equation in the left hand side.
Bode plots
MATLAB provides the bode function to sketch the Bode plot. To illustrate the application
of the bode function, consider the LTIC system which its transfer function is given by
Given H(s), the Bode plots are obtained in MATLAB using the following instructions:
In the above set of MATLAB instructions, we have used two new functions: tf and bode.
The built-in function tf specifies the LTIC system H(s) in terms of the coefficients of the
polynomials of s in the numerator and denominator. Since the numerator N(s) = 1, the
coefficients of the numerator are given by num coeff = 1. The denominator D(s) = s2 +
1.2s + 1. The coefficients of the denominator are given by denom coeff = [1 1.2 1].
The built-in function bode sketches the Bode plots. It accepts two input arguments.
The first input argument sys in used to represent the LTIC system, while the second input
argument {0.01,100} specifies the frequency range,0.01 radians/s to 100 radians/s, used to
sketch the Bode plots. In setting the values for the frequency range, we use the curly
parenthesis. Since the square parenthesis [0.01,100] represents only two frequencies, ω =
0.01 and ω = 100, it will result in the wrong plots. The second argument is optional.
If unspecified, MATLAB uses a default scheme to determine the frequency range for the
Bode plots.
Problem 6.2
Sketch the bold plot of the transfer function
Next ,this section will introduce the discrete Fourier transform (DFT) for time-limited
sequences as an extension of the DTFT where the DTFT frequency is discretized to a finite
set of values , for . The M-point DFT pair for a causal,
aperiodic sequence x[k] of length N is defined as follows:
For M = N, this implements the synthesis and analysis equations of the DFT in the matrix-
vector format as follows:
The columns (or equivalently the rows) of the DFT matrix define the basic functions for the
DFT.
Next, we consider using the M-point DFT X[r] to estimate the CTFT spectrum X(ω) of
an aperiodic signal x(t ) using the following relationship:
where T1 is the sampling interval used to discretize x(t), are the CTFT frequencies that are
given by for −0.5(M − 1) ≤ r ≤ 0.5(M − 1) ,and N is the number of samples
obtained from the CT signal.
Similarly, the DFT X[r] can be used to determine the DTFT X( ) of a time-limited sequence
x[k] of length N as
Using the DFT, estimate the frequency characteristics of the decaying exponential signal x(t )
= exp(−0.5t )u(t). Plot the magnitude and phase spectra.
Solution
Following the procedure outlined in this section, the three steps involved in computing the
CTFT are listed below.
Step 1: Impulse-train sampling The CTFT of the decaying exponential is given by
The figures (a) and (b) show graphical derivation of the discrete Fourier transform pair. (a) Original CT signal.
(b) CTFT of the original CT signal.
This CTFT pair implies that the bandwidth of x(t ) is infinite. Ideally speaking, the sampling
theorem can never be satisfied for the decaying exponential signal. However, we exploit the
fact that the magnitude |G(ω)| of the CTFT decreases monotonically with higher frequencies
and we neglect any frequency components at which the magnitude falls below a certain
threshold η. Selecting the value of η = 0.01 × |G(ω)|max, the threshold frequency B is given
by
Since the maximum value of the magnitude |X(ω)| is 2 at ω = 0, the above expression reduces
to
Since there is a discontinuity in the CT signal x(t) at t = 0 with x(0−) = 0 and x(0+) = 1, the
value of x[k] at k = 0 is set to x[0] = 0.5
The subscript w in xw [k] denotes the truncated version of x[k] obtained by multiplying by the
window function w[k]. Note that the truncated sequence xw [k] is a fairly good approximation
of x[k] , as the peak magnitude of the truncated samples is given by 0.0066 and occurs at k =
201. This is only 0.66% of the peak value of the complex exponential x[k].
The figures (illustrated above) show graphical derivation of the discrete Fourier transform pair
( continued to (k) and (l))
(m) Inverse DTFT of frequency-domain impulse train in part (n). (n) Frequency-domain impulse train.
(o) Inverse DTFT of part (p). (p) DTFT representation of CT signal in part (a).
(q) Inverse DFT of part (r). (r) DFT representation of CT signal in part (a).
Step 3: DFT computation The DFT of the truncated DT sequence xw [k] can now be
computed directly from DFT analysis equation. MATLAB provides a built-in function fft,
which has the calling syntax of
>> X = fft(x);
where x is the signal vector containing the values of the DT sequence xw [k] and X is the
computed DFT. Both x and X have a length of N (M=N), implying that an N-point DFT is
being taken. The built-in function fft computes the DFT within the frequency range
.
Since the DFT is periodic, we can obtain the DFT within the frequency range
by a circular shift of the DFT coefficients. In MATLAB, this is
accomplished by the fftshift function. Having computed the DFT, we use
to estimate the CTFT of the original CT decaying exponential signal x(t ). The MATLAB
code for computing the CTFT is as follows:
The resulting plots are shown in the figure (below), where we have limited the frequency axis
to the range −5π ≤ ω ≤ 5π. The magnitude and phase spectra plotted in the figures.
Spectral estimation of decaying exponential signal x(t ) = exp(−0.5t )u(t ) using the DFT in this example
(a) Estimated magnitude spectrum; (b) estimated phase spectrum.
The figures are fairly good estimates of the frequency characteristics of the decaying
exponential signal shown as follow.
In this example, we used the CTFT, X(ω), to determine the appropriate sampling rate.
In most practical situations, however, the CTFTs are not known and one is forced to make an
intelligent estimate of the bandwidth of the signal. If the frequency and time characteristics
of the signal are not known, a high sampling rate and a large time window are arbitrarily
chosen. In such cases, it is advised that a number of sampling rates and lengths be tried
before finalizing the estimates.
Solution
Step 2: DFT computation The MATLAB code for computing the DFT is as follows:
We observe that the values of the DFT coefficients are fairly close to the DTFT values.
Problem 7.1
Calculate the DTFT of the aperiodic sequence x[k] = [2, 0, 1, 1] for 0 ≤ k ≤ 3.
The DFT coefficients are given by
X[r] = [4, 0, 2, 2] for 0 ≤ r ≤ 3.
Mapping in the DTFT domain, the corresponding DTFT coefficients are given by
X( r) = [4, 0, 2, 2] for r= [0, 0.5π, π, 1.5π] radians/s.
If instead the DTFT is to be plotted within the range −π ≤ ≤ π, then the DTFT coefficients
can be rearranged as follows:
X( ) = [4, 0, 2, 2] for = [−π,−0.5π, 0, 0.5π] radians/s.
The magnitude and phase spectra obtained from the DTFT coefficients are sketched using
stem plots in figures (a) and (b) .For comparison; we use DTFT analysis equation to derive
the DTFT for x[k]. The DTFT is given by
an y[k] + an−1 y[k − 1]+· · ·+a0 y[k − n] = bm x[k] + b m−1 x[k − 1] + …+ b0x[k − m],
for modeling the relationship between the input sequence x[k] and output response y[k] of an
LTID system. MATLAB file filter used to compute the output response y[k] from spec-
ified sample values of the input sequence x[k] and the ancillary conditions. In this section, we
focus on the z-transfer function representation,
In terms of the transfer function in Eq. (13.48), the input variables B and A are defined as
follows:
A = [an an−1 . . . a0] andB = [bm bm−1 . . . b0].
The output parameter R returns the values of the partial fraction coefficients,P returns the
location of the poles, while K contains the direct term in the row vector.
Example 13.20
To illustrate the usage of the built-in function residuez, let us calculate the partial fraction
expansion of the z-transfer function,
The MATLAB code to determine the partial fraction expansion is given below. The
explanation follows each instruction in the form of comments.
The MATLAB code to determine the partial fraction expansion of the alternative expression
is given below. As before, the explanation follows each instruction in the form of comments.
>> B = [0; 0; 6; 34]; % Coeff. of the numerator N(z)
>> A = [1; -7; 31; -25]; % Coeff. of the D(z)
>> [R,P,K] = residue(B,A) % Calc. partial fraction expansion
They are obtained from the transfer function .The vector Z contains the location of the
zeros, vector P contains the location of the poles, while K returns a scalar providing the gain
of the numerator.
Problem 8.1
For the z-transfer function
Compute the poles and zeros and give a sketch of their locations in the complex z-plane.
Computing the z-transfer function from poles and zeros
MATLAB provides the built-in function zp2tf to calculate the z-transfer function from
poles and zeros. In terms of Eq. (13.49), the syntax for zp2tf is given by
>> [B,A] = zp2tf(Z,P,K); % Calculate poles and zeros
where vector Z contains the location of the zeros, vector P contains the location of the
poles, and K is a scalar providing the gain of the numerator. The numerator coefficients are
returned in B and the denominator coefficients in A.
Problem 8.2
Consider the poles and zeros calculated in the last problem. Using the values of the poles and,
zeros and the gain factor, determine the transfer function H(z).
The transfer function H(e j ) of a system represents a specific case of the system
function H(z) for z = e j . Based on the poles and zeros of the system function it is possible to
characterize system properties as causality or stability.