You are on page 1of 6

CL2014 MATLAB Programming

Lab work # 4

Title: Formulation to calculate flexural stress and plotting graph in


matlab
Student Name: MUEEZ ASIM
Student ID: 21L-5510
Date of Submission: 20/10/22

Grading Rubrics
Exemplary Proficient Developing Beginning Novice
Statement Score
(5) (4) (3) (2) (1)
1 Output/ Results Able to produce Able to Able to get Hardly able to Not able to
(40%) a high quality produce a some results produce the get any
code with code with from the code without results
desired output desired program with instructor’s from the
results. output major help program
having mistakes(s). without
minor instructors
mistake(s) help in
every step
2 Coding Style/ Able to write Able to write Used some of Used marginal None of
formatting (20%): program in program in the mentioned formatting the
Ability to use excellent good coding formatting techniques in formatting
coding style style missing techniques in the program. techniques
necessary commands
fulfilling all the 1-2 the program. were used
at the start of the
mentioned mentioned in the
program, provide criterion. criterion. program.
appropriate
description of
function, write
comments and use
proper indentation.
3 Coding Able to write Able to write Able to write Struggling to The student
Performance efficient code fairly good correct code in identify and is not able
with code with hardcoding correct the to identify
(20%): appropriate some logical without any errors in the and correct
Ability to write error handlers. errors or error handler. codes without the errors
appropriate error missing error help. in his code.
handlers and efficient handlers.
code without
hardcoding and
errors.
4 Lab Management Able to finish Able to Able to finish Struggling to Unable to
(20%): coding finish most most of the finish the code finish the
Time management complete in all of the coding coding within without code
aspects within within given given time instructors without
content organization
given time time missing missing 3-4 help instructors
1-2 criteria criteria help in
every step

Attained Score

Page 1 of 6
…………………….Start of MATLAB Code……………………….

clc
clear
%tutorial no : 4
%calculating flexural stresses
l= input (' enter length of beam l (ft) =\n') ; %length of beam
w= input (' uniformly distributed load w (kips/ft) =\n') ; %udl applied on beam
btf= input (' width of top flange btf (in) =\n') ; %width of top flange
ttf= input (' enter thickness of top flange ttf (in) =\n') ; %thickness of top flange
h= input (' enter total depth of section h (in) =\n') ; %total depth of section
hw= input (' enter height of web hw (in) =\n') ; %height of web
tw= input (' enter thickness of web tw (in)=\n') ; %thickness of web
td=ttf+hw; %total depth of section

%calculating maximum bending moment


M=(w*l^2)/2; %maximum bending moment in the beam

%calculation of distances of segmentes from centroid


af=btf*ttf ;%area of flange
aw=hw*tw;%area of web
df=(ttf/2)+hw; %distance of center of flange from bottom
dw=hw/2; %distance of center of web from bottom
c=((af*df)+(aw*dw))/(af+aw); %centroid of the section
cf=df-c; %distance of center of flange from centroid
cw=c-dw; %distance of center of web from centroid

%calculation of moment of inertia


If=((btf*ttf^3)/12)+(af*cf); %moment of inertia for flang
Iw=((tw*hw^3)/12)+(aw*cw); %moment of inertia for web
I=If+Iw; %total moment of inertia

%calculation of distance of centoid from top and bottom


x1=cf+(ttf/2); %distance from top to centroid
x2=c; %distance from bottom to centroid

% Now calculating Section Modulus.


St=I/x1 ; %This is Section Modulus for top.
Sb=I/x2 ; %This is Section Modulus for bottom.

%calculation of flexural stresses


y1=linspace(0,x1,10); %generating points for flexural stresses
y2=linspace(0,-x2,10); %generating points for flexural stresses
y=linspace(x1,-x2,20); %generating points for flexural stresses
f=(M*y)/I ;%flexural stresses
ft=(M*y1)/I ; %tension stresses

Page 2 of 6
fc=(M*y2)/I ; %compresion stresses
maxft=max(ft); %maximum tension stress
maxfc=max(fc);
minft=min(ft);
minfc=min(fc);%maximum compresion stress
txt1=['max tension : ' num2str(maxft) 'ksi'];
txt2=['max compression : ' num2str(minfc) 'ksi'];

%displaying results
disp ([' The Maximum Bending moment M = ' num2str(M) 'kipsft'])
disp ([' Centroid from top x1 = ' num2str(x1) 'inch'])
disp ([' Centroid from bottom x2 = ' num2str(x2) 'inch'])
disp ([' Moment of Inertia I = ' num2str(I) 'lb.sqin'])
disp ([' Section modulus from top St = ' num2str(St) 'in^3'])
disp ([' Section of modulus from bottom Sb = ' num2str(Sb) 'in^3'])
disp ([' different points y on the section = ' num2str(y) 'inch'])
disp ([' flexural stresses f = ' num2str(f) 'ksi'])
disp ([' tension stresses ft = ' num2str(ft) 'ksi'])
disp ([' compressive stresses fc = ' num2str(fc) 'ksi'])

%ploting graph
plot(ft,y1,'--rp')
title('FLEXURAL STRESS GRAPH ','Color','red')
xlabel('FLEXURAL STRESSES (ksi)','color','black'),
ylabel('Length (in)','color','black' )
grid on
hold on
plot(fc,y2,'--bh')
hold on
plot([0,0],[0,x1],'-k','linewidth',4)
hold on
plot([0,0],[0,-x2],'-k','linewidth',4)
hold on
plot([0 , maxft],[x1,x1] ,'-k')
hold on
plot([0 , minfc],[-x2 ,-x2],'-k')
hold on
text(maxft,x1,txt1)
hold on
text(minfc,-x2,txt2)

……………………….End of MATLAB Code……………………….

Page 3 of 6
…………………….Start of Results……………………….

enter length of beam l (ft) =


20
uniformly distributed load w (kips/ft) =
2
width of top flange btf (in) =
4
enter thickness of top flange ttf (in) =
1
enter total depth of section h (in) =
8
enter height of web hw (in) =
7
enter thickness of web tw (in)=
1
The Maximum Bending moment M = 400kipsft
Centroid from top x1 = 3.0455inch
Centroid from bottom x2 = 4.9545inch
Moment of Inertia I = 49.2803lb.sqin
Section modulus from top St = 16.1816in^3
Section of modulus from bottom Sb = 9.9465in^3
different points y on the section = 3.0455 2.6244 2.2033 1.7823 1.3612
0.94019 0.51914 0.098086 -0.32297 -0.74402 -1.1651 -1.5861 -2.0072 -
2.4282 -2.8493 -3.2703 -3.6914 -4.1124 -4.5335 -4.9545inch
flexural stresses f = 24.7194 21.3018 17.8842 14.4666 11.049 7.63138
4.21376 0.796149 -2.62147 -6.03908 -9.45669 -12.8743 -16.2919 -19.7095
-23.1271 -26.5448 -29.9624 -33.38 -36.7976 -40.2152ksi
tension stresses ft = 0 2.74661 5.49321 8.23982 10.9864 13.733 16.4796
19.2262 21.9728 24.7194ksi
compressive stresses fc = 0 -4.46836 -8.93672 -13.4051 -17.8734 -22.3418 -
26.8101 -31.2785 -35.7469 -40.2152ksi
>>

Page 4 of 6
……………………….End of Results……………………….

Page 5 of 6
Page 6 of 6

You might also like