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

MATLAB..... The flow rate Qin m^3/s in an open channel of circular cross-section

ID: 3111677 • Letter: M

Question

MATLAB.....

The flow rate Qin m^3/s in an open channel of circular cross-section shown in the figure below is given by Q = 2^3/2 D^5/2_c squareroot g(theta - 0.5 sin(2 theta))^3/2/^8 squareroot sin theta (1 - cos theta)^5/2 where g = 9.8 m/s^2 is the gravitational constant and D_c is given by D_c = d/2 (1 - cos theta) Note that the units for theta in these equations is radians. Create at least one function handle for this equation, which has has two input, diameter d and angle theta. Use the function handles to compute flow rate Q, and print the table shown above. Note that in the table, theta is in degrees.

Explanation / Answer

function [ Q ] = cheggfunction( d,th )

g=9.8;
th = deg2rad(th);
D= (d/2)* (1 - cos(th));
Q = ((2^1.5) .* (D.^2.5) .* (g^0.5) .*(th - 0.5 .* sin(2 .* th)).^1.5)./ (8 .* (sin(th)).^0.5 .* (1 - cos(th)).^2.5);

end

well, as per the question, we need to write a function which takes two argument as input and returns Q, as output.

The above function works properly as per question need and prints the exact table for the different value of d (here,d=2 and d=4).

I am explaining the code step by step. As your question is in MATLAB, I hope you will be familiar with basic of MATLAB. So, Here we go:

step 1: open the function script in MATLAB and replace the output argument with Q and input arguments with d, theta (here, I used 'th' for notation of theta).

step 2: First define g=9.8 as gravitational constant. You will note that theta is given in degree in the table and equation needs theta into radian. So, we need to convert theta into radian which is done by using deg2rad() function.

step 3: We need to calculate Dc (In code, Dc is replaced with D for avoiding complexity). Here, one thing needs to be noted down that if the user gives input in the form of the array then D also returns array and in the next step, all the operation is used with .*, ./ and .^ instead of ordinary multiplication, division, and power because we need to compute element wise operation.

step 4: Here, simply we need to write down the expression using simple operation. As I already explained in the previous step that we need element wise operation in the array, so we need to take care of operation used for element wise operation in the array.

Finally, we have desired output in hand, just you need to enter correct input.

th=10:5:60
d=2
W= cheggfunction(d,th)

'th' used for theta and it returns an array begins with 10 and ends at 60 with the increment of 5. The value of 'd' is 2 and 4. Simply, call the function and you will get your output.

If you any query related in the question and in MATLAB, feel free to ask.

Have a good day!!