ChE210 Sample Final

Embed Size (px)

Citation preview

  • 7/30/2019 ChE210 Sample Final

    1/10

    Name:

    ChE 210

    Final ExamSaturday, May 14, 2010

    Answer the following questions in the space provided. MATLAB syntax will be expected to be correct. Your

    work must be readable to receive full credit and only one answer per question is allowed. If there is extra

    work on a page, box the answer you want graded.

    Allowed MATLAB functions are: trigonometric functions (regular and inverse), sqrt, log functions, exp, abs,

    rem, length, size, ones, zeros, rounding/truncating functions. If you think I have missed a useful functionplease ask before you use it.

    A note about repetition: I expect the proper MATLAB repetition commands to be used for number and

    condition based repetition.

    1. Force vectors are often described using polar coordinates (magnitude and angle); however when several

    forces act on an object the resultant overall force and direction can best be calculated by calculating the

    rectangular components of the vectors (Fx and Fy), putting them in vectors and then summing the vectors

    to get the resultant. Then the resultant can be changed back into polar coordinates.

    Two tugboats are pulling on a large barge that must go directly down a river. The two tugs pull with

    different amounts of force in different directions. Write a script that asks the user for the magnitude and

    direction for each of the two tugs and then calculates the resultant force and direction. The program will

    print resultant force and direction. Use fprintf statements to print a nicely formatted output.

    Equations:

    Polar to Rectangular Rectangular to Polar

    cos

    sin

    x

    y

    F F

    F F

    =

    =

    2 2 2

    tan

    x y

    y

    x

    F F F

    F

    F

    = +

    =

    F is magnitude of a vector. is direction. Fx and Fy are the x and y components of the vector.

  • 7/30/2019 ChE210 Sample Final

    2/10

  • 7/30/2019 ChE210 Sample Final

    3/10

    2. Write a MATLAB function that accepts two arguments p and x. The first is a vector of polynomial

    coefficients p and the second is a scalar x. The functions return value is to be the value of the polynomial

    p evaluated at x. A polynomial has the form

    1 2

    1 2 1( )

    n n

    n np x p x p x p x p

    = + + + +

    Example: p(x) = 3x5

    7x3

    + 2x2

    + 5x 4 p = [ 3 0 -7 2 5 -4 ]

    The form of your function is y = polyv( p , x ). The function does not have to check to make sure that p is a

    vector or that x is scalar.

  • 7/30/2019 ChE210 Sample Final

    4/10

    3. Now that you have written polyv( p , x ) write a second function multipoly( p , x ) that uses polyv( p , x ) to

    evaluate arguments where x can be any size, scalar, vector (both row and column), or matrix. The p

    argument is the same as before. The function is to return evaluations of the polynomial for each element

    in x (scalar in scalar out, matrix in matrix out).

  • 7/30/2019 ChE210 Sample Final

    5/10

    4. When a baseball is thrown from the outfield to home-plate it follows the well known rules for projectile

    flight.

    8.1

    cos2

    tan2

    0

    22

    0

    0+= x

    v

    gxy

    Assume a ball is thrown to home from center field ( x = 90m ). If it is well thrown, when it arrives at

    home-plate the value of y will be zero. Assuming the ball is thrown with a velocity v0=25m/sec

    everything is known except for the throwing angle 0. Since the left-hand side of the equation

    becomes zero we can use fzero to determine the proper throwing angle.

    Write a function toss( theta , distance , velocity ) that describes the problem. Note that x and v are

    included in the function so that we can examine more cases than this specific example. Write the

    necessary command-line commands ( >> ) that would solve the problem with the given parametersusing an anonymous function call and fzero.

  • 7/30/2019 ChE210 Sample Final

    6/10

    5. Basic expressions MATLAB and Excel. Evaluate the following numerical expressions:

    a. 2+4^2/2

    b. 2-12/2*3

    c. 8+12/3+1

    d. ((2+3)^2)/(8-(2+1))

  • 7/30/2019 ChE210 Sample Final

    7/10

    6. Simple Logicals: Understanding logical expressions is key to using MATLAB if and while constructions.

    Evaluate the follow logical expressions answering either true or false. Assume a = 20; b = 2; c = 1; d = 2;

    a. a > b

    b. a < b & c < d

    c. a == b

    d. a | b < c

    e. a < d < c

  • 7/30/2019 ChE210 Sample Final

    8/10

    7. A group of students have measured the quantity of water discharged from a tank as a function of time.

    The data are shown plotted on the following page as a normal plot, a semi-log plot and a log-log plot.

    What, if anything can you conclude about the type of equation that might be used to represent the data.

  • 7/30/2019 ChE210 Sample Final

    9/10

  • 7/30/2019 ChE210 Sample Final

    10/10

    8. In MATLAB the use of matrix vetor math can be a big time saver. Evaluate the following expressions:

    a. [ 1 , 2 ; 3 , 4 ] * [ 5 , 6 ; 0 1 ]

    b. [ 1 , 2 ; 3 , 4 ] .* [ 5 , 6 ; 0 1 ]

    c. 2 \ [ 4 , 2 , 1 ]

    d. [ 2:3:8 ]