KNS1482 ENGINEERING PROGRAMMING
MATLAB Report
Assignment 2
Title: Flow Characteristics for Open Channels (Trapezoidal)
Lecturer: Dr Ir Yunika Kirana
Group Members : 1. Nadzirah Binti Rasaie (102772)
2. Nurain Batrisyia Binti Senu (105767)
3. Martin Wong Soon Cheng (102671)
4. Ling Jie (104775)
5. Esther Melanie Sum (104059)
1
Table of Content:
CONTENTS PAGE
1. INTRODUCTION 3-4
2. OBJECTIVES 5
3. RESULT
3.1 Formula & Manual Calculations 6-8
3.2 MATLAB script and coding 9-10
3.3 MATLAB graph 11
4. DISCUSSION 12
5.CONCLUSION 13
6. REFERENCES 14
7. APPENDIX 15
2
1. INTRODUCTION
According to Moler (2006), MATLAB was first introduced in December 1980, but it
became significantly more stable by September 2015. Developed by MathWorks,
MATLAB—short for Matrix LABoratory—is a proprietary, multi-paradigm programming
language and numerical computing environment. It enables users to manipulate matrices,
visualize data and functions, develop algorithms, build user interfaces, and integrate with
programs written in other languages.
While MATLAB is mainly designed for numerical computations, it also supports
symbolic computing through an optional toolbox powered by the MuPAD symbolic engine.
Additionally, the Simulink add-on provides graphical simulation and model-based design
capabilities for dynamic and embedded systems. By 2020, MATLAB had gained more than four
million users worldwide from various fields such as engineering, science, and economics. As of
2017, over 5,000 universities and colleges globally utilized MATLAB for teaching and research
purposes.
MATLAB offers a desktop environment optimized for iterative analysis and design,
paired with a programming language that naturally handles matrix and array operations. It
includes the Live Editor, which lets users create interactive scripts combining code, results, and
formatted text in a single notebook. Today, millions of engineers and researchers use MATLAB
in both industry and academia for applications ranging from machine learning and deep learning
to signal processing, image and video analysis, control systems, testing and measurement,
computational finance, and computational biology.
In this assignment, we are required to determine the depth of flow for a specific section
provided in the table below using Chezy’s equation. Ensure that no repetition of the same data
occurs across different groups. Chezy’s equation is utilized to calculate the discharge of flow in
an open channel, as follows:
𝑄 = 𝐴𝐶𝑅21𝑆21
3
where Q is the discharge, A is the cross-sectional area of the flow, C is the Chezy
coefficient, R is the hydraulic radius, and S is the slope of the channel. We were also
required to use MATLAB to generate a graph showing the variation of the calculated depth
of flow for the selected section by varying Q = (0.5:0.5:5)Qi where Qi is the initial Q given
in the table. Plot depth vs Q using MATLAB. For the same conditions, the width, b is now
2b, 4b, and 6b. Replot and we need to discuss our results.
4
2. OBJECTIVES
This assignment aims to study the characteristics of uniform flow in open channels through the
application of Chezy’s equation. The analysis will be carried out using MATLAB to model the
equation, explore different flow scenarios, and examine how variables such as slope and
hydraulic radius influence flow velocity.
5
3.1 Formula and Manual Calculations
Qi = 0.8 m3/s
s = 0.013 m/m
b = 1.7 m
c = 0.002
Chezy Equation, Q = ACR1/2 S1/2
Rearrange the equation,
Let = u --------(1)
From the question, Q = (0.5:0.5:5) Qi
Q = 5(0.8) = 4.0 m3/s
Substitute the known values,
u= =
u = 17541.16
6
Assume x = 1, because it is not given
Area, A = (b + xy)y
A = (1.7 + y) y
Wetted perimeter, P =
P=
P=
Hydraulic Radius, R =
R=
From equation (1),
Trial and error,
Substitute y = 60.474 m into equation (1),
7
u=
u = 17541.30 ≈ 17541.16
Therefore, y = 60.474 m
8
3.2 MATLAB script and coding:
close;
clc;
clear;
% Given data from table for trapezoidal section
Qi = 0.8; % Initial discharge (m^3/s)
S = 0.013; % Trapezoidal Channel Slope (m/m)
C = 0.002; % Chezy coefficient
b= 1.7; % Initial Base width (m)
%assume x=1 because it is not given
x=1;
% Discharge vector
Q_vector = (0.5:0.5:5)*Qi;
% Widths for different cases
b_cases = [1*b, 2*b, 4*b, 6*b];
% b,2b,4b,6b = [2.4,4.8,9.6,14.4]
% Matrix to store depths
depths = zeros(numel(b_cases), numel(Q_vector)); % numel() function returns the number of elements
% Output length(b_cases) = 4 elements
% Output length(Q_vector) = 10 elements
% Solve depth based on each width cases and discharge
% Main loops
for i = 1:numel(b_cases) % Loop runs once for each element in the array of b_cases
b_current = b_cases(i); % Access to i-th element to obtain the current width
for j = 1:numel(Q_vector) % Loop runs once for each element in the array of Q_vector
Q_current = Q_vector(j); % Access to j-th element to obtain the current discharge
% Initial guess for depth of flow and incremental
y_initial = 1; % Balance initial depth of flow between 0.1:1.0
y_increment = 1; % Balance incremental for depth of flow between 0.001:0.01
% Iterative search as y increase until Q_chezy proximate or just exceeds Q_target
while true
A = (b_current+x*y_initial)*y_initial; % Trapezoidal open channel's cross-sectional area (A)
P = b_current+2*y_initial*sqrt(1+x^2); % Trapezoidal open channel's Wetted perimeter (P)
R = A/P; % Hydraulic Radius (R)
Q_chezy = A*C*sqrt(R*S); % Chezy Equation Q = ACR^(1/2)S^(1/2)
% stop if close enough or just over
if abs(Q_chezy-Q_current)<0.0001 || Q_chezy>Q_current
break
end
y_initial = y_initial + y_increment; % Small step increment to approach Q_current
end
9
depths(i,j) = y_initial; % Store computed depth y into matrix depths at current channel width & current discharge
end
end
% Plotting the graph of depth against Discharge for various bottom widths
figure(1);
hold on;
% create 2D lines
% plot(x-axis data, y-axis data, 'Line Style and Marker', Thickness of the line, Line color, plot function, dynamic label
text)
plot(Q_vector, depths(1,:), '-d', 'Linewidth', 1.5, 'Color', 'b', 'DisplayName', sprintf('b = %.1f m', b_cases(1)));
plot(Q_vector, depths(2,:), '-d', 'Linewidth', 1.5, 'Color', 'k', 'DisplayName', sprintf('2b = %.1f m', b_cases(2)));
plot(Q_vector, depths(3,:), '-d', 'Linewidth', 1.5, 'Color', 'm', 'DisplayName', sprintf('4b = %.1f m', b_cases(3)));
plot(Q_vector, depths(4,:), '-d', 'Linewidth', 1.5, 'Color', 'c', 'DisplayName', sprintf('6b = %.1f m', b_cases(4)));
% Add details information into graph
xlabel('Discharge flow, Q (m^3/s)');
ylabel('Depth of flow, y (m)');
title('Depth of flow vs Discharge flow based on different Widths');
legend('location','northwest');
grid on;
hold off;
10
3.3 MATLAB graph:
Figure 1: Graph depth of flow vs. Discharge flow on different width
11
4. DISCUSSION
In this assignment, the relationship between discharge (Q) and flow depth (y) in a trapezoidal
open channel was analyzed using the Chezy equation. The focus was on Case No. 13, with a
given discharge of 0.8 m³/s, a slope (S) of 0.013, a channel width of 1.7 m, and a very low Chezy
coefficient (C) of 0.002. Due to the implicit nature of the Chezy equation with respect to flow
depth, it could not be solved analytically. Therefore, a numerical approach was needed to
estimate the depth corresponding to given flow and channel conditions.
A MATLAB program was developed to perform this analysis. It tested a series of depth values
(y) iteratively until the resulting discharge from the Chezy equation matched the input value. The
program simulated a range of discharges from 0.5Qi to 5Qi and calculated the corresponding
depths. This allowed for a detailed evaluation of how flow depth changes with discharge and
how the trapezoidal channel geometry influences this relationship.
The extremely low value of the Chezy coefficient (0.002) greatly affected the depth calculations.
Since a smaller C results in lower velocities, the required depths to maintain a certain discharge
became unrealistically large. For instance, with a width of 1.7 m, achieving a discharge of 0.8
m³/s required a very high flow depth. Even as the width increases or discharge varies, the results
consistently indicated exaggerated depth values due to the inefficiency implied by such a low
Chezy coefficient.
Initially, the fzero function in MATLAB was used to solve for the flow depth within a standard
range of [0, 5]. However, the solver failed to converge within this range due to the unusually
small C value, which limited flow capacity significantly. To overcome this, the depth search
range was expanded to [0, 100000], enabling the program to find a solution. Although the
resulting depths were still unrealistically large, adjusting the range was necessary to capture the
correct behavior of the Chezy equation under these conditions.
12
5. CONCLUSION
In conclusion, we were able to study the relationship between flow depth and discharge using
MATLAB, a powerful tool for technical computing. By applying the Chezy equation and
inputting the necessary parameters, we created a graph in figure 1 that shows how discharge
increases with flow depth. This analysis helped us understand how channel geometry and flow
resistance affect water movement. Although some results appeared unrealistic due to certain
parameter values, the overall trend remained consistent with hydraulic principles. This shows
how numerical methods can effectively support the analysis of open channel flow behavior.
13
References:
1. Mohr, S., Bairán, J. M., & Marí, A. R. (2010). A frame element model for the analysis of
reinforced concrete structures under shear and bending. Engineering structures, 32(12),
3936-3954.
2. Recupero, A., D’Aveni, A., & Ghersi, A. (2005). Bending moment–shear force
interaction domains for prestressed concrete beams. Journal of Structural Engineering,
131(9), 1413-1421.
3. Tsang, Y. M., Poon, A. S., & Addepalli, S. (2011, December). Coding the beams:
Improving beamforming training in mmwave communication system. In 2011 IEEE
Global Telecommunications Conference-GLOBECOM 2011 (pp. 1-6). IEEE.
4. Vasdravellis, G., & Uy, B. (2014). Shear strength and moment-shear interaction in
steel-concrete composite beams. Journal of Structural Engineering, 140(11), 04014084.
Appendix:
Figure 2 : Group discussion at Petary
Figure 3 : Task Division at Whatsapp Group
14