0% found this document useful (0 votes)
4 views22 pages

Project Programming

The document outlines a project for the Engineering Programming course at Universiti Malaysia Sarawak, focusing on analyzing the behavior of a simply supported beam under various loading conditions using MATLAB. It includes details on project objectives, calculations for maximum deflection, shear force, and bending moment, as well as pseudocode and MATLAB code for implementation. The project aims to enhance understanding of structural integrity through computational analysis and visualization of results.

Uploaded by

Veronica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views22 pages

Project Programming

The document outlines a project for the Engineering Programming course at Universiti Malaysia Sarawak, focusing on analyzing the behavior of a simply supported beam under various loading conditions using MATLAB. It includes details on project objectives, calculations for maximum deflection, shear force, and bending moment, as well as pseudocode and MATLAB code for implementation. The project aims to enhance understanding of structural integrity through computational analysis and visualization of results.

Uploaded by

Veronica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

UNIVERSITI MALAYSIA SARAWAK

FACULTY OF ENGINEERING
CIVIL ENGINEERING DEPARTMENT

KNS1482
ENGINEERING PROGRAMMING
PROJECT

Title PROJECT

Date 29 JUNE 2024

Lecturer DR FAUZAN BIN SAHDI

1.Mohd Irfan Muqri Bin Mohd Jaffrizal (97543)

2.Eric Jong Chia Shen (101668)

3.Muhammad Fakhrul Hilmi Bin Mohamad Fadzil


Group (97575)
Members
4.Mohamad Khairul Nizam Rajemi (82679)

5.Muhammad Arif Hafizin bin Safarizal (97570)

6.Febian anak Dockey (98951)


FACULTY OF ENGINEERING
FORMAT 1 (CPS)
KNS1482 Engineering Programming
Semester 2 Session 2023/2024

Project with CPS Rubric (40 Marks)

Student Name :
Matric No. : Programme:
:
Project/Assignment Title :

Instruction: Please rate your student according to the marking criteria below. Fill in column “MARKS’ with allocation marking criteria (marks in decimal point is not acceptable).
Criteria statement should align with the element of CO, PO, WK and WP where applicable.

Marking Criteria
Criteria Description WK WP/EA Weightage Marks Remark
0 1 2 3 4 5
CO2, PO2
Criteria 1 -Construction of a pseudocode
Demonstrate the with good/clear working
ability to explain the structure/flowchart
overarching
concept/idea of the Not Very
2 Poor Fair Good Excellent 1.25
engineering provided poor
programming
algorithm/process.

Criteria 3 -MATLAB script constructed


Demonstrate ability to excellently with usage of for-
write a script to plot loops, subplot function.
Not Very
beam shear force 3 Poor Fair Good Excellent 5
provided poor
diagram, bending
moment and deflection

Criteria 3 - MATLAB code saves all the


Demonstrate the required outputs in .xls format
ability to produce a
script that saves Not Very
3 Poor Fair Good Excellent 1.25
deflection, shear force provided poor
and bending moment
data in .xls file
Criteria 4 Demonstration of full
Demonstrate the knowledge of the subject
ability to produce a with excellent
brief report that clearly explanations and 3
Not Very
Poor Fair Good Excellent 2.5
explains how the elaboration. provided poor
programme works and
its output

Total Mark, Wxn:

Final S(Wxn)/50 x
40:

Detail description of the marking criteria:

Comments:

Examined by : Signature :

Date :
Note : Scale for marking criteria is flexible (Example : 0 – 10)
TABLE OF CONTENT

NO CONTENTS PAGE
1. INTRODUCTION 1-2
2, OBJECTIVE 3
3. CALCULATION 4-5
4. PSEUDOCODE 6–9
5. GRAPH 9
6. MATLAB CODE 10 - 13
7. MATLAB ELABORATION 14 - 15
8. SCRIPT OUTPUT 16
9. CONCLUSION 16 - 17
10. REFERENCES 18
INTRODUCTION

An essential component of engineering mechanics and design is the analysis of


structural beams under various loading scenarios. With the use of computational analysis in
MATLAB, this research seeks to investigate the behaviour of a simply supported beam under
a variable distributed load. By creating a MATLAB software, each group must ascertain the
beam's reactions, including its location and maximum deflection. Plotting deflection, shear
force, and bending moment diagrams under various loading scenarios is part of the analysis.

The forces in the members and their displacements are found using the theory of
structural analysis (Hibbeler, 2020). A simply supported beam is a fundamental structural
component used in many engineering applications, such as the framework of buildings and
bridges. For the purpose of guaranteeing structural integrity and safety, it is essential to
comprehend its behavior under various loading scenarios.

In order to vary parameters like the dispersed load intensity (q0), beam length (Li), and
beam width (Wi) systematically, the project uses three different loading conditions. The
distributed load intensity (qi) is set at 100 N/m in the beginning conditions given for these
parameters. Given the specified width (Wi= 0.14 m), depth (di=0.10 m), and initial length
(Li= 4.2 m) for the wood beams. MATLAB used in performing the calculation and results
obtained were saved in an Excel file.

The breadth and load intensity were held constant while the beam length was adjusted.
Because longer beams are more flexible, they deflect more, and the maximum deflection
location varies in proportion to the length of the beam. The number of moving forces, which
may be functions of time and spatial coordinate, and their velocities are arbitrary (Pesterev et
al., 2000). The length of the beam had an effect on the bending moment and shear force. The
values at the supports increased with the length of the beam, although the maximum values
still happened around the middle of the section bearing a triangular load.

1
Elements of the beam design in different loading situations. The MATLAB model
effectively captured the distributions of the bending moment, shear force, and deflection. Our
findings highlight the significance of optimizing beam length, width, and load intensity to get
the best performance while maintaining structural integrity. Moreover, experimental
validation of the simulation results would yield useful insights into the behaviour of real-
world structures. To be a good architects you need to be able to communicate well with
structural engineers (Kenneth Marvin Leet et al., 2011).

2
OBJECTIVE

1. Creating a MATLAB programme to calculate and plot the beam's bending moment, shear
force, and deflection diagrams in different type and various situations.

2. Put all of the beam parameters and properties using the MATLAB Command Window.

3. The programme is analysed into three situations :

Condition 1: The constant values for other parameters are maintained but the distributed
load (qo) is modified

Condition 2: The constant values for other parameters are maintained but the beam length
(L) is modified

Condition 3: The constant values for other parameters are maintained but the beam width
(W) is modified

3
CALCULATION

CALCULATE MOMENT OF INERTIA

I = (bd^3) / 12

For Group 23 :
b = 0.14 m
d = 0.10 m

I = (0.14×(0.10)^3) / 12

I = (0.14×0.001) / 12

I = 0.00014 / 12

I = 1.1667×10^-5 m^4

CALCULATE THE LOCATION OF THE MAXIMUM DEFLECTION

x = L /2 = 4.2 / 2 = 2.1m

CALCULATE THE MAXIMUM DEFLECTION


At ( x = 0 ),

δ(0) = ((10) / (24 x 70 x 10^9 x 1.1667 x 10^(-5))) x (0 (4.2^3 - 2 x 4.2 x 0^2 + 0^3))
= 0 mm

At ( x = 2.1 ),

δ(2.1) = ((10) / (24 x 70 x 10^9 x 1.1667 x 10^(-5))) x (2.1 (4.2^3 - 2 x 4.2 x 0^2 + 0^3))
= ((10) / (24 x 70 x 10^9 x 1.1667 x 10^(-5))) x (2.1 (46.305))
= 971.805 / 1.964634×10 ^ 6
= 0.495 mm

At ( x = 4.2 m),

δ(0) = ((10) / (24 x 70 x 10^9 x 1.1667 x 10^(-5))) x (4.2(4.2^3 - 2 x 4.2 x 4.2^2 + 4.2^3))
= 0 mm

4
CALCULATE THE SHEAR FORCE AND BENDING MOMENT

Shear Force (V):


At x = 0 m
V(0) = ((10 x 4.2) / 2) -10 (0)
= 21 N

At x = 2.1 m
V(2.1) = ((10 x 4.2) / 2) -10 (2.1)
=0N

At x = 4.2 m
V(4.2) = ((10 x 4.2) / 2) -10 (4.2)
= - 21 N

Bending Moment (M):


At x = 0 m
M(0) = ((10 x 0) / 2)(4.2 - 0)
= 0 Nm

At x = 2.1 m
M(0) = ((10 x 2.1) / 2)(4.2 - 2.1)
= (21 x 2.1) / 2
= 22.05 Nm

At x = 4.2 m
M(0) = ((10 x 4.2) / 2)(4.2 - 4.2)
= 0 Nm

5
PSEUDOCODE

BEGIN

// Prompt user for initial conditions


qi = INPUT("Enter the initial uniform distributed load (qi) in N/m: ")
Li = INPUT("Enter the initial beam length (Li) in meters: ")
Wi = INPUT("Enter the initial beam width (Wi) in meters: ")
di = INPUT("Enter the initial beam depth (di) in meters: ")

// Material properties
E = 70e9 // Young's modulus for Aluminum in Pa

// Calculate the initial moment of inertia


Ii = (Wi * di^3) / 12

// Define the variable ranges for each condition


qo_values = [qi, 2*qi, 3*qi]
L_values = [Li, 2*Li, 3*Li]
W_values = [Wi, 2*Wi, 3*Wi]

// Placeholder for results


results = [["Condition", "qo (N/m)", "L (m)", "W (m)", "Max Deflection (m)", "Max
Deflection Location (m)"]]

// Initialize color order for plotting


colors = predefined_color_set(9)
legend_entries = []

// Loop through each condition for varying qo


FOR each qo IN qo_values DO
L = Li // Fixed length
W = Wi // Fixed width
I = Ii // Fixed moment of inertia

// Call the beam calculation function


[x, y, V, M, max_deflection, max_location] = calculate_beam_deflection(qo, L, W, di,
E, I)

// Store results
APPEND results WITH ["Condition 1", qo, L, W, max_deflection, max_location]

// Plot data
plot_results(x, y, V, M, colors[current_index], "Condition1", current_index)
APPEND legend_entries WITH ["Condition 1: qo = ", qo, " N/m"]
END FOR

// Loop through each condition for varying L


FOR each L IN L_values DO

6
qo = qi // Fixed distributed load
W = Wi // Fixed width
I = Ii // Fixed moment of inertia

// Call the beam calculation function


[x, y, V, M, max_deflection, max_location] = calculate_beam_deflection(qo, L, W, di,
E, I)

// Store results
APPEND results WITH ["Condition 2", qo, L, W, max_deflection, max_location]

// Plot data
plot_results(x, y, V, M, colors[current_index], "Condition2", current_index)
APPEND legend_entries WITH ["Condition 2: L = ", L, " meters"]
END FOR

// Loop through each condition for varying W


FOR each W IN W_values DO
qo = qi // Fixed distributed load
L = Li // Fixed length
I = (W * di^3) / 12 // Moment of inertia changes with width

// Call the beam calculation function


[x, y, V, M, max_deflection, max_location] = calculate_beam_deflection(qo, L, W, di,
E, I)

// Store results
APPEND results WITH ["Condition 3", qo, L, W, max_deflection, max_location]

// Plot data
plot_results(x, y, V, M, colors[current_index], "Condition3", current_index)
APPEND legend_entries WITH ["Condition 3: W = ", W, " meters"]
END FOR

// Save summary results with descriptive headers


SAVE "summary_results.xls" WITH results

// Add legends to the plots


ADD_LEGENDS_TO_PLOTS(legend_entries)

END

FUNCTION calculate_beam_deflection(qo, L, W, d, E, I)
// Discretize the beam
x = linspace(0, L, 1000)

// Define the load distribution function


q = FUNCTION(x) RETURN qo * (x - (L/3)) / (L/3) * (x >= L/3 AND x <= 2*(L/3))

7
// Initialize deflection, shear force, and moment arrays
V = ZERO_ARRAY(LENGTH(x))
M = ZERO_ARRAY(LENGTH(x))
y = ZERO_ARRAY(LENGTH(x))

// Calculate shear force and bending moment


FOR i FROM 2 TO LENGTH(x) DO
dx = x[i] - x[i-1]
V[i] = V[i-1] + q(x[i-1]) * dx
M[i] = M[i-1] + V[i-1] * dx
y[i] = y[i-1] + (M[i-1] / (E * I)) * dx
END FOR

// Find maximum deflection and its location


max_deflection = MAX(abs(y))
max_location = x[INDEX_OF(max_deflection)]

RETURN [x, y, V, M, max_deflection, max_location]


END FUNCTION

FUNCTION plot_results(x, y, V, M, color, condition, idx)


// Plotting deflection
SUBPLOT(3, 1, 1)
HOLD_ON
PLOT(x, y, color)
TITLE("Deflection")
YLABEL("Deflection (m)")

// Plotting shear force


SUBPLOT(3, 1, 2)
HOLD_ON
PLOT(x, V, color)
TITLE("Shear Force")
YLABEL("Shear Force (N)")

// Plotting bending moment


SUBPLOT(3, 1, 3)
HOLD_ON
PLOT(x, M, color)
TITLE("Bending Moment")
YLABEL("Bending Moment (Nm)")
XLABEL("Position along the beam (m)")
END FUNCTION

FUNCTION ADD_LEGENDS_TO_PLOTS(legend_entries)
SUBPLOT(3, 1, 1)
LEGEND(legend_entries)

SUBPLOT(3, 1, 2)

8
LEGEND(legend_entries)

SUBPLOT(3, 1, 3)
LEGEND(legend_entries)
END FUNCTION

GRAPH

Figure 4.1 Graph of Deflection, Shear Force and Bending Moment

9
MATLAB CODE

1. Main

% Prompt user for initial conditions


qi = input('Enter the initial uniform distributed load (qi) in N/m: ');
Li = input('Enter the initial beam length (Li) in meters: ');
Wi = input('Enter the initial beam width (Wi) in meters: ');
di = input('Enter the initial beam depth (di) in meters: ');
% Material properties
E = 70e9; % Young's modulus for Aluminum in Pa
% Calculate the initial moment of inertia
Ii = (Wi * di^3) / 12;
% Define the variable ranges for each condition
qo_values = qi * (1:1:3);
L_values = Li * (1:1:3);
W_values = Wi * (1:1:3);
% Placeholder for results
results = {'Condition', 'qo (N/m)', 'L (m)', 'W (m)', 'Max Deflection
(m)', 'Max Deflection Location (m)'};
% Create a figure for all conditions
figure;
% Initialize color order for plotting
colors = lines(9);
legend_entries = {};

10
2. Conditions

% Loop through each condition


for idx = 1:length(qo_values)
qo = qo_values(idx);
% Condition 1: Varying qo
fprintf('\nCondition 1: Varying qo = %.2f N/m\n', qo);
L = Li; % Fixed length
W = Wi; % Fixed width
I = Ii; % Fixed moment of inertia
% Call the beam calculation function
[x, y, V, M, max_deflection, max_location] =
calculate_beam_deflection(qo, L, W, di, E, I);
% Store results
results = [results; {'Condition 1', qo, L, W, max_deflection,
max_location}];
% Plot data
plot_results(x, y, V, M, colors(idx,:), 'Condition1', idx);
legend_entries{end+1} = ['Condition 1: qo = ', num2str(qo), ' N/m'];
end
for idx = 1:length(L_values)
L = L_values(idx);
% Condition 2: Varying L
fprintf('\nCondition 2: Varying L = %.2f meters\n', L);
qo = qi; % Fixed distributed load
W = Wi; % Fixed width
I = Ii; % Fixed moment of inertia
% Call the beam calculation function
[x, y, V, M, max_deflection, max_location] =
calculate_beam_deflection(qo, L, W, di, E, I);
% Store results
results = [results; {'Condition 2', qo, L, W, max_deflection,
max_location}];
% Plot data
plot_results(x, y, V, M, colors(length(qo_values) + idx,:),
'Condition2', idx);
legend_entries{end+1} = ['Condition 2: L = ', num2str(L), ' meters'];
end
for idx = 1:length(W_values)
W = W_values(idx);
% Condition 3: Varying W
fprintf('\nCondition 3: Varying W = %.2f meters\n', W);
qo = qi; % Fixed distributed load
L = Li; % Fixed length
I = (W * di^3) / 12; % Moment of inertia changes with width
% Call the beam calculation function
[x, y, V, M, max_deflection, max_location] =
calculate_beam_deflection(qo, L, W, di, E, I);
% Store results
results = [results; {'Condition 3', qo, L, W, max_deflection,
max_location}];
% Plot data
plot_results(x, y, V, M, colors(length(qo_values) + length(L_values) +
idx,:), 'Condition3', idx);
legend_entries{end+1} = ['Condition 3: W = ', num2str(W), ' meters'];
end
% Save summary results with descriptive headers
xlswrite('summary_results.xls', results);
% Add legends to the plots
subplot(3,1,1);

11
legend(legend_entries);
subplot(3,1,2);
legend(legend_entries);
subplot(3,1,3);
legend(legend_entries);

12
3. Deflection, Shear Force and Bending Moment

% Function to calculate beam deflection, shear force, and bending moment


function [x, y, V, M, max_deflection, max_location] =
calculate_beam_deflection(qo, L, W, d, E, I)
% Discretize the beam
x = linspace(0, L, 1000);
% Define the load distribution function
q = @(x) qo * (x - (L/3)) / (L/3) .* (x >= L/3 & x <= 2*(L/3));

% Initialize deflection, shear force, and moment arrays


V = zeros(size(x));
M = zeros(size(x));
y = zeros(size(x));

% Calculate shear force and bending moment


for i = 2:length(x)
dx = x(i) - x(i-1);
V(i) = V(i-1) + q(x(i-1)) * dx;
M(i) = M(i-1) + V(i-1) * dx;
y(i) = y(i-1) + (M(i-1) / (E * I)) * dx;
end

% Find maximum deflection and its location


[max_deflection, max_index] = max(abs(y));
max_location = x(max_index);
end

4. Result Plotting

% Function to plot results


function plot_results(x, y, V, M, color, condition, idx)
% Plotting
subplot(3,1,1);
hold on;
plot(x, y, 'Color', color, 'DisplayName', [condition, ' ',
num2str(idx)]);
title('Deflection');
ylabel('Deflection (m)');
subplot(3,1,2);
hold on;
plot(x, V, 'Color', color, 'DisplayName', [condition, ' ',
num2str(idx)]);
title('Shear Force');
ylabel('Shear Force (N)');
subplot(3,1,3);
hold on;
plot(x, M, 'Color', color, 'DisplayName', [condition, ' ',
num2str(idx)]);
title('Bending Moment');
ylabel('Bending Moment (Nm)');
xlabel('Position along the beam (m)');
end

13
MATLAB ELABORATION

1. Initialization

The script starts with the first instruction to the user to enter the beam length (‘L’). It
also initializes a distributed load (‘q_i’) at 100 N/m. These values are necessary for the
further calculation of the necessary parameters.

2. Material Properties

Material properties for an example group (e. g. , Steel) are initialized with specific
values: For the initial length it was assigned (‘Li’) (4. 2 metres), for the initial width
(‘Wi’) (0. 14 metres) and for the initial depth (‘di’) (0. 10 metres). These properties
shall be employed in the determination of various conditions of the structure in
question.

3. Define Different Conditions

Three arrays are defined to represent different conditions by scaling the initial values:
For distributed loads we have ‘q_o’ for overall load, ‘L_conditions’ for the beam length,
and ‘W_conditions’ for beam width. Each of the arrays increases the respective first
term by factors of one, two and three.

4. Preallocate Arrays for Results

Arrays for results such as ‘deflections’, ‘shear forces’, and ‘bending moments’ are
created and pre-initialized to zeros. All the arrays include three numbers, which pertain
to the three states that shall be tested for.

14
5. Loop over Conditions

The first for loop cycles through the aforementioned three sets of conditions to obtain
the current length, load, and width. Thereafter, it determines the deflection, shear force,
and bending moment using function proxies namely ‘calculate_deflection’,
‘calculate_shear_force’ and ‘calculate_bending_moment’. These calculations’
outcomes are kept in the predetermined arrays, which help in the subsequent
calculations.

6. Save Results to .xls File

The results for deflections, shear forces and bending moments are written into an Excel
file with the name ‘beam_responses.xls’. This can be easily done in other statistical
packages after copying and pasting the output data from Matlab.

7. Plotting Results

The ‘plot_beam_responses’ function produces the plots of the deflections, shear forces,
and bending moments with the length of the beam in interpretation. This visualization
is useful in enabling understanding on how the beam behaves under any given
circumstances.

8. Function Definitions

Three procedures namely; ‘calculate_deflection’,’calculate_shear_force’ and


‘calculate_bending_moment’ are provided to carry out the required computation.
Different functions employ a placeholder formula which has to be superseded by a more
precise formula based on beams’ theory. There is another function
‘plot_beam_responses’ that is defined to plot the calculated results to get the qualitative
determination of the nature of the beam under different situations in this class.

15
SCRIPT OUTPUT

CONCLUSION

In order to comprehend beam behaviour in structural engineering, this research focuses


on the computational analysis of a simply supported beam under a varied distributed load using
MATLAB (Hibbeler, 2020). Finding out how various loading scenarios impact a beam's
structural integrity and safety—two important factors in building and bridge design is the main
goal.

The study demonstrates that a beam's length has a major impact on its deflection, with
longer beams showing more flexibility and deflection. This relationship highlights how crucial
it is to take beam length into account when designing structures in order to guarantee
performance and safety. The paper illustrates how distributed load intensity and beam size
affect structural responses by examining different loading scenarios. As a starting point for

16
comparison, the initial conditions are specified for length (4.2 m), width (0.14 m), depth (0.10
m), and distributed load intensity (100 N/m).

The resulting bending moment and shear force diagrams offer important insights into
the internal forces of the beam, which are essential for comprehending how the beam responds
to various loading scenarios and locating stress areas that could require further strengthening.
The study shows how the structural behaviour of a beam is affected by methodically changing
some factors, including distributed load intensity and beam length, while maintaining other
values constant. A deeper comprehension of the interactions between many design aspects is
made possible by this all-encompassing approach.

The results can be directly applied to practical engineering situations, allowing


structural engineers and architects to make well-informed judgements on beam design and
guaranteeing that structures can safely support anticipated loads. The utilisation of Excel for
storing results and MATLAB for computational analysis demonstrates how well these
programmes work for carrying out intricate structural calculations and precisely and efficiently
handling data.

Last but not least, as Kenneth Marvin Leet et al. (2011) pointed out, good
communication is essential between structural engineers and architects. This study emphasises
how crucial teamwork is to producing the best structural designs that satisfy practical and
aesthetic standards. To sum up, this research offers a comprehensive examination of simply
supported beams under changing distributed loads, providing insightful knowledge about their
structural behaviour and assisting in the creation of safer and more effective structural designs.

17
REFERENCES

Hibbeler, R. C. (2020). Structural analysis. Pearson Education Limited.

Hibbeler, R. C. (2020). Engineering Mechanics: Statics & Dynamics (15th ed.). Pearson.

Kenneth Marvin Leet, Chia-Ming Uang, & Gilbert, A. M. (2011). Fundamentals of

structural analysis. Mcgraw-Hill.

Leet, K. M., Uang, C.-M., & Gilbert, A. M. (2011). Fundamentals of Structural Analysis (4th

ed.). McGraw-Hill Education.

Pesterev, A. V., Tan, C. A., & Bergman, L. A. (2000). A New Method for Calculating

Bending Moment and Shear Force in Moving Load Problems. Journal of Applied

Mechanics, 68(2), 252–259. https://doi.org/10.1115/1.1356028

18

You might also like