Assignment 7: Integration and ODEs Problem 1
Assignment 7: Integration and ODEs Problem 1
Assignment 7: Integration and ODEs Problem 1
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
CEE 3804: Computer Applications in Civil Engineering Spring 2010<br />
Date Due: April 8, 2010 (Class Time)<br />
<strong>Problem</strong> 1<br />
<strong>Assignment</strong> 7: <strong>Integration</strong> <strong>and</strong> <strong>ODEs</strong><br />
Instructor: Trani<br />
Steel is one of the most important materials used in Civil Engineering. A civil engineer wants to estimate the distribution of the<br />
Modulus of Elasticity (Young’s modulus) for various specimens of steel beams received from a factory. The engineer collects data<br />
<strong>and</strong> finds that the modulus of elasticity is normally distributed. The equation of the Probability Density Function (PDF) of the<br />
Gaussian (or Normal) distribution is given in any statistics textbook <strong>and</strong> repeated here for completeness (http://en.wikipedia.org/<br />
wiki/Normal_distribution).<br />
−<br />
1<br />
f (x) =<br />
σ 2π e<br />
⎡ (x− µ )2 ⎤<br />
⎢<br />
⎣ 2σ 2 ⎥<br />
⎦<br />
where: x is the r<strong>and</strong>om variable in question (modulus of elasticity in psi) <strong>and</strong> µ <strong>and</strong> σ are the mean <strong>and</strong> st<strong>and</strong>ard deviation (in<br />
psi) of the r<strong>and</strong>om phenomena modeled. After testing 100 samples, the engineer estimates the mean modulus of elasticity to be<br />
2.856 e7 psi. The st<strong>and</strong>ard deviation is found to be 4.1e5.<br />
The area under probability density function has a fundamental interpretation in r<strong>and</strong>om processes. For example, the area under<br />
the curve in Figure 1 can be interpreted as the probability that r<strong>and</strong>om variable x will take values between a <strong>and</strong> infinity.<br />
Figure 1. Sample Normal Probability Density Function. Interpretation of the Area Under the Curve.<br />
Create a Matlab script to estimate the probably that steel samples meet the design criteria that more than<br />
75% of the samples need to be above 2.75e7 psi.<br />
Take the area under the curve from 2.75e7 to infinity (a large number). The area under the curve is:<br />
0.9949<br />
CEE 3804 Trani Page 1 of 6
Task 4<br />
Using your Matlab function <strong>and</strong> scripts, verify that the area under the Normal curve is equal to one.<br />
Script to calculate area under the curve.<br />
___________<br />
% Normal Distribution Analysis<br />
% A.A. Trani<br />
% Function calls:<br />
global MU SIGMA<br />
% Define the parameter of the distribution (MU) <strong>and</strong> st<strong>and</strong>ard deviation (SIGMA)<br />
MU = 2.856e7;<br />
SIGMA = 4.1e5;<br />
% Define upper <strong>and</strong> lower bounds to get a nice plot of the Gaussian PDF<br />
npoints = 100;<br />
parameter = 3.5;<br />
low = MU - parameter*SIGMA;<br />
high = MU + parameter* SIGMA;<br />
interval = (high - low) / npoints;<br />
ub = MU + parameter* SIGMA;<br />
lb = 2.75e7;<br />
CEE 3804 Trani Page 2 of 6
% Define r<strong>and</strong>om variable<br />
x=low:interval:high;<br />
% Define the function of the r<strong>and</strong>om variable x (PDF function)<br />
fx = 1/(SIGMA * sqrt(2*pi)) * exp(-1/2 * ((x-MU)/SIGMA).^2 );<br />
% Plot the r<strong>and</strong>om variable x versus the PDF function<br />
plot(x,fx)<br />
xlabel('R<strong>and</strong>om variable - x')<br />
ylabel('f(x)')<br />
grid<br />
% Compute area under the curve f(x) from -infinity to infinity<br />
% Change the values of the last two arguments if you<br />
% want another range of values<br />
area=quad('normalg',lb,ub);<br />
disp(' ')<br />
disp([blanks(5),'Area under the Normal Distribution : '])<br />
disp(' ')<br />
disp([blanks(5),' P(x>0)=',num2str(area)])<br />
disp(' ')<br />
_____________<br />
Function Normalg.m<br />
____________<br />
% Function to evaluate the area under the normal distribution<br />
% Passes back a single argument containing f(x) for the normal PDF function<br />
function f = normalg(x);<br />
global MU SIGMA<br />
f = 1./(SIGMA .* sqrt(2*pi)) .* exp(-1/2 .* ((x-MU)./SIGMA).^2 );<br />
CEE 3804 Trani Page 3 of 6
<strong>Problem</strong>s 2-3<br />
The differential equation to predict the acceleration dv<br />
dt<br />
dv<br />
dt = k 1 + k 2 v + k 3 v2<br />
of a high-speed train is given by the formula:<br />
where: k 1<br />
, k 2<br />
, <strong>and</strong> k 3<br />
are coefficients of the high-speed train <strong>and</strong> v is the speed of the high-speed train (in meters/second) .<br />
In the equation presented, the dimensions of the acceleration are m/s 2 . The values of the coefficients are: 0.39, -0.0033 <strong>and</strong><br />
-3.2e-5, respectively.<br />
Solution:<br />
dV<br />
= k 1<br />
+ k 2<br />
V + k 3<br />
V 2<br />
dt<br />
x 1<br />
= speed<br />
x 2<br />
= position<br />
xdot 2<br />
= x 1<br />
xdot 1<br />
= k 1<br />
+ k 2<br />
V + k 3<br />
V 2<br />
The Matlab main script is:<br />
__________________<br />
% Main file to execute the equations of motion of the HS Train<br />
% A. Trani<br />
% Solution to a set of equations of the form:<br />
%<br />
% x(1) = speed (m/s)<br />
% x(2) = position (m)<br />
%<br />
% xdot(2) = x(1);<br />
% xdot(1) = k1 + k2 * x1 + k3 * x1^2<br />
%<br />
% subject to initial conditions:<br />
%<br />
% x (t=0) = xo<br />
%<br />
% where:<br />
clear<br />
CEE 3804 Trani Page 4 of 6
global k1 k2 k3<br />
% Define the Initial Conditions of the <strong>Problem</strong><br />
xo = [0 0];<br />
to = 0.0;<br />
tf = 300;<br />
% xo are the initial position <strong>and</strong> speed of the train<br />
% to is the initial time to solve this equation<br />
% tf is the final time (seconds)<br />
% define m <strong>and</strong> b<br />
k1 = 0.39; %<br />
k2 = -0.0033; %<br />
k3 = -3.2e-5; %<br />
tspan =[to tf];<br />
[t,x] = ode15s('trainProfile',tspan,xo);<br />
% call ODE solver<br />
% Plot the results of the numerical integration procedure<br />
figure<br />
plot(t,x(:,1),'o-r')<br />
xlabel('Time (seconds)')<br />
ylabel('Speed (m/s)')<br />
grid<br />
figure<br />
plot(t,x(:,2),'^--k')<br />
xlabel('Time (seconds)')<br />
ylabel('Position (m)')<br />
grid<br />
___________<br />
Function trainProfile.m<br />
________________<br />
% Two first-order DEQ to solve the train system<br />
function xdot = trainProfile(t,x)<br />
global k1 k2 k3<br />
% define the rate equations of the train system<br />
%<br />
% x(1) = speed (m/s)<br />
% x(2) = distance traveled (m)<br />
% xdot(1) = rate of change of speed vs time = acceleration<br />
CEE 3804 Trani Page 5 of 6
% xdot(2) = rate of change of distance vs time = speed<br />
xdot(2) = x(1);<br />
xdot(1) = k1 + k2 * x(1) + k3 * x(1).^2;<br />
xdot = xdot';<br />
The plots are shown below.<br />
CEE 3804 Trani Page 6 of 6