Você está na página 1de 2

# CE 206 (Engineering Computation Sessional)

Assignment #1
Instructor: Dr. Tanvir Ahmed

Q1. Mannings equation can be used to compute the velocity of water in a rectangular
open channel
3 / 2
2

+
=
H B
BH
n
S
U
Where U = velocity (m/s), S = channel slope, n = roughness coefficient, B = width (m)
and H = depth(m). The following is available for five channels:

n S B H
0.035 0.0001 10 2
0.020 0.0002 8 1
0.015 0.0010 20 1.5
0.030 0.0007 24 3
0.022 0.0003 15 2.5

Store these values in a single matrix where each row represents one of the channels and
each column represents one of the parameters. Write a single-line MATLAB statement
to compute a column vector containing the velocities bases on the values in the
parameter matrix.

Q2. The Maclaurin series expansion for the cosine is
........
! 8 ! 6 ! 4 2
1 cos
8 6 4 2
+ + =
x x x x
x

Use MATLAB to create a plot of the cosine (solid line) along with a plot of the series
expansion (dashed line) up to and including the term x
6
/6!. Use the built-in function
factorial in computing the series expansion. Make the range of the abscissa from x = 0 to
3/2.

Q3. It is general practice in engineering and science that equations be plotted as lines
and discrete data as symbols. Here is some data for concentration (c) versus time (t) for

t (min) 10 20 30 40 50 60
c (ppm) 3.4 2.6 1.6 1.3 1.0 0.5
The data can be described by the following function:
t
e c
034 . 0
84 . 4

=

(a) Use MATLAB to create a plot displaying both the data (using square symbols) and
function (using dashed line). Plot the function for t = 0 to 70 min

(b) Use the semilogy function to plot the data and function as described in part (a).
State the nature of change in the curve from part (a) to (b) and try to explain why this
happened.

Q4. Modify plotSin function shown in class to to do the following:
- If only one input is given (f1), it only evaluates z = stn(J
1
x) while if two inputs
are given (f1 and f2), it evaluates z = stn(J
1
x) +us (J
2
y)
The limits of both x and y are from 0 to 2
- In the top axis of your subplot, display an image of the Z matrix. Display the
colorbar and use a hot colormap. Set the axis to xy (use these commands to
perform the tasks: imagesc, colormap, colorbar, axis)
- In the bottom axis of the subplot, plot the 3-D surface of z (use the surf
command)
[Look at the MATLAB help file for the reference of any commands not discussed
in class]

Finally execute your command for a two-input case (e.g. say, plotSin(5,4)) and
generate the plots.