Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Matlab Question: The Manning formula is an empirical formula estimating the aver

ID: 656220 • Letter: M

Question

Matlab Question:

The Manning formula is an empirical formula estimating the average velocity of a liquid flowing in a conduit that does not completely enclose the liquid, that is, an open channel flow.1 All flow in so-called open channels is driven by gravity. The flow formula for a rectangular channel can be written as where Q is the flow (m3/S), nm is a roughness coefficient, B is the width of the channel (m), H is the depth (m), and S is the slope. You are applying this formula to a stream where you know that the width is 20 m and the depth is 0.3 m. Unfortunately, you know the roughness and the slope to only a 10 % precision. That is, you know that 0.00033. Assuming uniform distributions, use a Monte Carlo analysis with n = 10,000 to estimate the distribution of the flow. In other words, generate vectors of 10,000 uniformly distributed values each for nm and S within their respective ranges and perform the Monte Carlo analysis. Write a function called calcQ that takes a seed for the random number generator as the input parameter and returns two values: Qmean and Qstd, the mean and standard deviation of the Q values, respectively. The function template is as follows:

Explanation / Answer

for the random number generator

unsigned int RNG()

{

    // our initial starting seed is 5323

    static unsigned int nSeed = 5323;

    // Take the current seed and generate a new value from it.

    nSeed = (8253729 * nSeed + 2396403);

    // Take the seed and return a value between 0 and 32767

    return nSeed  % 32767;

}

for the mean and standard deviation