INTRODUCTION
The Laplace transform offers significant advantages for modeling
continuous-time physical systems versus
linear differential equations with constant coefficients. The transformed
differential equations are algebraic,
and hence are easier to solve. We have learned many ways to solve differential
equations using Laplace
transforms last semester in lab 4 (The lab is located on the ECE 311 website
under the Computer Labs
link). In this lab we will review how to use the Laplace transform to solve
differential equations, change the
result from frequency-domain to time-domain using the inverse Laplace transform,
and simulate the result
using MATLAB’s SIMULINK toolbox. The other goal of this lab is to build analog
filters using
SIMULINK and study their function by filtering various (noisy) signals.
REVIEW OF MATLAB TOOLS
In ECE 311, we learned:
1. Finding the roots of a polynomial using ‘roots’

2. Multiplying Polynomials using ‘conv’

3. Adding Polynomials . Only polynomials with the same length can be added
together.
m=length(x); n=length(y);
if m>=n
z=x+[zeros(1,m-n),y];
else
z=y+[zeros(1,n-m),x];
end
4. Evaluating Polynomials using ‘polyval’

5. For typical systems the transfer function can be ex pressed as a rational
function, such as

6. Partial Fraction Expansion using ‘residue’
»b=[1 0 1]; % B(s)
»a=[1 6 11 6]; % A(s)
»[gamma,alpha,k]=residue(b,a)
gamma =
5.0000
-5.0000
1.0000
alpha =
-3.0000
-2.0000
-1.0000
k = []
7. Inverse Laplace Transform using ‘ilaplace’ (this was not introduced in ECE
311)
» syms F s
» F=(s^2+1)/(s^3+6*s^2+11*s+6);
»ilaplace(F)
ans =
5*exp(-3*t)-5*exp(-2*t)+exp(-t)
8. Plotting Complex Frequency Response of H(s) using ‘freqs’
» b=[1 0 1];
» a=[1 6 11 6];
» freqs(b,a)
% The output of this is seen in Figure One below.

Figure One Output of ‘freqs’
9. Create Bode Diagrams using ‘bode’ (frequency response with dB magnitude
plot)
» sys=tf([1 0 1],[1 6 11 6]);
» bode(sys)
% This is shown in Figure Two below.

Figure Two Bode plot of the same system from Figure One
SIMULINK
Now we wish to use SIMULINK to simulate the system, e.g., see the output when
the input is a step
function (see the Figure Three below). SIMULINK is a powerful simulation tool
provided by MATLAB.
It al lows for analysis /simulation of interconnections of dynamic systems (both
continuous-time and
discrete-time).
You can easily build models from scratch, or take an existing model and edit
it. Simulations are interactive,
so you can change parameters “on the fly” and immediately see what happens. In
this lab you will be
learning to use SIMULINK.

Figure Three SIMULINK diagram for the step response
of the system used in Figures One and Two
Running, Plotting, Printing
In Math -software/second-order-ode-solver.html">order to see a demonstration of a ( fairly complex ) SIMULINK diagram type
»thermo at the MATLAB
prompt (see Figure Four below). Open the scope block, labeled “Thermo Plots” by
double clicking, and
then run the simulation using the buttons or pull down menus provided. You can
print the plot of the
simulation output (scope block) and also print the simulation model itself.
Model Building
Figure Three above shows a SIMULINK model for an ODE. You can launch the
SIMULINK library
browser from within MATLAB by using the button or typing: »simulink at the
command prompt. Then
open a new model (using button or pull down menus), and build a copy of the
above model. This is
achieved by dragging components from the library to the model and connecting
them using the mouse.
Double clicking a box then allows you to edit the contents, such as entering
values for the transfer function
(as shown above).
Look around at the (many) available blocks in SIMULINK. You will certainly
need to look in Sources,
Sinks, Continuous, Math. When you have built a copy of the model save it with
the name “myode” (it will
actually be saved as myode.mdl). You can then launch this model later from
MATLAB simply by typing
»myode at the command line. Go under Simulation to Parameters and you can change
the simulation
time. You can then run the simulation and print the results from the scope block
(note the autoscale button
on the scope).
Having completed this exercise you should have a model plot and a simulation
run. You can now try
varying the ODE and input parameters, and easily see how they affect the
solution (note also that you can
enter variable names in SIMULINK blocks if you like , and it will read them from
the MATLAB
workspace).

Figure Four Thermo demo in SIMULINK
ASSIGNMENT
1. Calculate the poles, zeros, and impulse response of the following
differential equation; plot the
frequency response; Compute and plot the output via Simulink when the
input is a unit step function.
Compute and plot the analytical expression for the output y(t), and
compare this to the result obtained
using Simulink.
 |
ANALOG FILTERS
We have learned about analog filters such as Butterworth and Chebychev
filters in lab 4 for ECE 311. In
this lab we’ll use SIMULINK to filter noisy signals using these filters.
FURTHER ASSIGNMENT
2. Build a 6th order lowpass Butterworth filter with a cutoff frequency
of 1kHz, and plot its frequency
response. 3. Build two sinusoidal signals,
one with a frequency of 10Hz, and the other with a frequency of 100Hz,
using Simulink. Add them, and then filter the combined signal using a 6th
order lowpass Butterworth
filter with a cutoff frequency of 30Hz (as an example see the file
twosine.mdl on the webpage under
‘SIMULINK files for lab 1’, which you can edit). Plot the output signal
(using a scope block), and
explain what you see. What is the connection between the time and
frequency domain response, and
how is this evident on this signal (which is a superposition of two
signals at different frequencies).
You can also try different combinations of frequencies to see the effect
of this filter. 4. We know that a periodic
signal can be expressed as a sum of sinusoid signals with Fourier
coefficients. Download the SIMULINK model square.mdl from the webpage
under ‘SIMULINK files
for lab 1’ (see Figure Five below), run it, and explain in detail what
you see. Comment on the effects
of the filter in time and frequency domain, and how this correlates to
its frequency response (transfer
function). Comment also on how these effects are evident on the
individual components and the entire
(superposed) signal (note that all the signals are available via scope
blocks). Include any relevant plots
from the simulation. You can also try alternatives to the very simple
(1/(s+1)) filter implemented here. |

Figure Five SIMULINK diagram in ‘square.mdl’