You are on page 1of 8

# Name: insert name here

## MECH 2220 MATLAB Lab 2Numerical Integration Spring 2013 Page 1 of 8

Numerical Integration Lab Assignment
Assigned: March 4, 2013
Due: your next lab meeting (after spring break)
Name: insert name here
MECH 2220 MATLAB Lab 2Numerical Integration Spring 2013 Page 2 of 8
Problem Statement #1:
Write two user written functions to perform numerical integration using the
trapezoid method and Simpsons One Third Method, which you will name
trap_method and Simpsons_1_3 respectively. Your function must accept the
following arguments for both functions: an independent vector of numbers and a
dependent vector of numbers. Your function file must perform the following tasks:
a) Check that both vectors are of equal length.
b) Check that the independent vector in the Simpsons Method has equal
spaced intervals.
c) Compute numerically using trapezoid method and return the
value of the integral.
d) Compute numerically using Simpsons One Third method and
return the value of the integral.
Code for problem #1:
Paste code here
Solution for problem #1:
No output required
Name: insert name here
MECH 2220 MATLAB Lab 2Numerical Integration Spring 2013 Page 3 of 8
Problem Statement #2:
The force on a sailboat mast can be represented by the following function:
Where z is the elevation above the deck and H is the height of the mast. The
total force F exerted by the mast and the line of action d can be determined by
the following integrals
a) Use trapezoidal rule to compute the integral numerically given H=25, n=9.
b) Repeat step (a) using Simpsons 1/3 rule.
Code for problem #2:
Paste code here
Solution for problem #2:
Give solution/output here
Name: insert name here
MECH 2220 MATLAB Lab 2Numerical Integration Spring 2013 Page 4 of 8
Problem Statement # 3:
Problem 3 is based on a water level control simulation.
List of variables:
Tank dimensions:
D=tank diameter
H=tank height
Water level:
y=water level
y
i
=initial water level
y
sp
=desired water level (i.e. setpoint)
Controller:
DT=time step between measurements of water level
BAND=control band centered about the setpoint
k
I
=integration gain constant
Inlet Valve:
V
imax
=maximum inlet volumetric flow rate
Out flow:
V
out
=outlet volumetric flow rate
Name: insert name here
MECH 2220 MATLAB Lab 2Numerical Integration Spring 2013 Page 5 of 8
Name: insert name here
MECH 2220 MATLAB Lab 2Numerical Integration Spring 2013 Page 6 of 8
Problem Statement #3a:
On/Off Control
The length of time between water level measurements/ control adjustments is DT.
If the water level drops to the bottom of the band, the controller drives the inlet
valve to 100% open.
The valve stays 100% open until the water level reaches the top of the band.
When the water level reaches the top of the band, the controller drives the inlet
valve to the fully closed position.
The inlet valve remains fully closed until the water level once again drops to the
bottom of the band.
1. Write a script that prompts the user for the required inputs. Simulate
water level control for the following inputs:
Tank dimensions:
D=5 feet
H=10 feet
Water level:
y
i
=7 ft
y
sp
=5 ft
Controller:
DT=30 seconds
BAND=1 ft
k
I
=not used
Inlet Valve:
V
imax
=100 gallons per minute
Out flow:
V
out
=40 gallons per minute
2. Plot the water level as a function of time. Plot horizontal lines for the
setpoint, upper, and low band limits. Label and legend the plot appropriately:
Name: insert name here
MECH 2220 MATLAB Lab 2Numerical Integration Spring 2013 Page 7 of 8
Problem Statement #3b:
Proportional Control
The length of time between water level measurements/ control adjustments is DT.
The controller drives the inlet valve to a position ranging from 0 to 100%.
If the water level is at or above the top of the band, the proportional output is 0.
If the water level is at or below the bottom of the band, the proportional output to
the inlet valve is 100%.
When the water level is within the limits of the band, the proportional output
varies linearly from 0% at the top of the band to 100% at the bottom of the band.
1. Write a script that prompts the user for the required inputs. Simulate
water level control for the following inputs:
Tank dimensions:
D=5 feet
H=10 feet
Water level:
y
i
=7 ft
y
sp
=5 ft
Controller:
DT=2 seconds
BAND=1 ft
k
I
=not used
Inlet Valve:
V
imax
=100 gallons per minute
Out flow:
V
out
=40 gallons per minute
2. Plot the water level as a function of time. Plot horizontal lines for the
setpoint, upper, and low band limits. Label and legend the plot appropriately:
Name: insert name here
MECH 2220 MATLAB Lab 2Numerical Integration Spring 2013 Page 8 of 8
Problem Statement #3c:
Proportional & Integral Control (PI control)
The length of time between water level measurements/ control adjustments is DT.
The controller drives the inlet valve to a position ranging from 0 to 100%.
The controller output is set by the following:
SV= ( )
sp
0
min max +.5+k y y , 0 ,1 *100%
t
sp
I
y y
dt
band
1 _

1
' ;
1 , ]

1. Write a script that prompts the user for the required inputs. Simulate
water level control for the following inputs:
Tank dimensions:
D=5 feet
H=10 feet
Water level:
y
i
=7 ft
y
sp
=5 ft
Controller:
DT=2 seconds
BAND=1 ft
k
I
=.007
Inlet Valve:
V
imax
=100 gallons per minute
Out flow:
V
out
=40 gallons per minute
2. Plot the water level as a function of time. Plot horizontal lines for the
setpoint, upper, and low band limits. Label and legend the plot appropriately: