Textbook Notes (280,000)
US (100,000)
LSU (20,000)
ME (300)
All (5)
Chapter

# HW 3 SolutionExam

Department
Mechanical Engineering
Course Code
ME 3143
Professor
All

This preview shows pages 1-3. to view the full 19 pages of the document.
1
ME 3143
Fall 2011
Problem Set 3 Solution
1. Simulink™ is a graphical user interface to Matlab™ for dynamic
simulations. System models can be built from block diagrams using
libraries of predefined function blocks; an example is shown at the bottom
of the page that represents the differential equation:.
!
! "
( )
=!!
! "
( )
!
"
( )
=#!\$
Simulink™ can pull data in from Matlab™ and send data to Matlab™ for
plotting, so the full capabilities of both programs are available.
(a) Build the model shown at the bottom of the page:
i. Initiate Simulink™ by typing: simulink in the
Matlab™ command window;
ii. Open a new model window in Simulink™, if one does
not open automatically;
iii. Find the blocks for the model in different libraries. The
Integrator will be in the Continuous Library. Others will
be as follows: Gain (), Scope and To Workspace
(Sinks Library), and Clock (Sources Library). Drag
and drop the blocks in your model window. Connect
the blocks by dragging the port on a block to the one
it should be connected to a line representing a link
will form and the arrowhead will appear if the link is
made;

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

ME 3143 F’11 Problem Set 3 Solution
2
iv. Block properties are set by clicking on the block to
open a properties window. Set the gain as shown and
the initial condition on the Integrator block;
v. The Scope and To Workspace blocks are used for the
output of the simulation. Doubleclicking on a Scope
block will open a display that shows the output of the
simulation as a function of time. The To Workspace
blocks transfer the data to Matlab and set up a
variable containing the data there so that it can be
processed further or plotted.
(b) Directly integrate the differential equation. Store your result
and the corresponding time values in Matlab™ as:
y(1,:) = A*exp(-[0:0.1:4]/
!
);
t1 = [0:0.1:1.0];
What is the time constant, τ, for the system?
(c) Use Simulink™ to numerically integrate the equation using
the Euler integration scheme (using fixed step integrations
and the solver ode1 from the Configuration Parameters
menu). Run simulations for integration time steps of
!
,
0.1
!
,
0.01
!
, and
0.001
!
where
is the time constant for the
system. Save the time (t2,t3,t4,) and output vectors
(y2,y3,) for each of your five simulation runs. In Matlab™,
save your data in the same array as the solution from (b)
y(2,:) = y2(:);
y(3,:) = y3(:);
(d) Compare your result to the direct integration from (b) by
plotting them on the same plot using the Matlab™ plot
command:
plot(t1,y(1,:),t2,y(2,:),t3,y(3,:),t4,y(4,:),t5,y(5,:));
You can label and grid your plot using legend, xlabel, ylabel,
and grid commands. Linetype and line color are controlled in
the plot command.
What differences do you see between the exact solution and
the numerically integrated solutions? Does it change with the
size of the integration time step?

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

ME 3143 F’11 Problem Set 3 Solution
3
Given: A first order differential equation.
Find: (a) Build the Simulink model; (b) Integrate the homogeneous
equation directly and plot the results; (c) Use the Simulink model to
numerically integrate the equation using time steps of
!
,
0.1
!
,
0.01
!
,
and
0.001
!
; (d) Plot (b) and (c) on the same plot.
Solution: (a) The given block diagram is shown below with key
variables labeled. The lines in a block diagram represent variables or
signals and the blocks are operations that are performed on those
signals.
(b) The differential equation for the system is:
!"
!#
=!!"#
"
"
!"
"
=!!"#
!#
"\$%
"
=!!"#
#
+
\$
&
Rearranging and integrating yields the result on the right. Take the
exponential of both sides of the equation:
!
!"
"
=
!
!#\$%
#
+
\$
&"
"
'
#
(=
!
\$
&
!
!#\$%
#
"
"
'
#
(=
\$
)
!
!#\$%
#
Apply the initial conditions:
!
!
( )
="# =
"
\$!
! #
( )
="#
\$
"#%!
#
The time constant, τ, for the system is 0.20 seconds and the constant,
A, is 15. Use those to generate the data in Matlab™ and plot the
analytical solution
y(1,:) = 15*exp(-[0:0.1:1.0]/0.20);
t1 = [0:0.1:1.0];
The plot is shown on the next page. The exponential curve should
decay by 98% after four time constants (t = 4
τ
) and 99.3% after five
time constants, which it appears to do.
(c) In order to store all of the amplitude values, including the exact solution
from (b) and the numerically integrated results from Simulink, in a
single array it must be sized to hold the longest vector – the one for the
smallest integration time step. Use the size command to find out the
length of each amplitude (and time) vector, then define the matrix y =
zeros(5,nmax). This creates an array 5 X nmax filled with zeroes that
can be replaced by the actual data. Replace each row with the
Simulink output as follows:
###### You're Reading a Preview

Unlock to view full version