Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 41

CHAPTER ONE

1. INTRODUCTION
1.1 Orientation of Student
1.1.1 Orientation at CUIB
I am a sophomore student in the school of engineering and the department
of civil and environmental engineering.
1.2 Objectives of Carrying out the Internship
 Creating an application in MATLAB that uses the concept of my Applied
Mechanics Course in calculating the shear and moment forces that are
applied on a beam by loads, plotting the respective shear and moment
diagrams of the forces acting on a beam.
 To learn the design of beams and loads in 2D in the engineering software
(MATLAB).
 To increase my performances in MATLAB.
 To improve my programming skills.

1
CHAPTER TWO

2.1 Background of the Company


My orientation in my civil engineering career is more focused on software
development for civil engineers which will help automate structural engineering
task of civil engineers. Since there is no company in Cameroon that specializes in
this domain, I took permission from my dean Dr Sona Alfred, the dean of school
of engineering to work with Eng. Gouater Loic Dimitri who is a Professional Free-
Lancer in MATLAB/SIMULINK. He does Computational engineering, and he
automates task for engineers in the electrical, mechanical or civil engineering
fields using MATLAB. I worked with this professional because working with him
I acquired a lot of skills which I need in order to be able to achieve my goal of
software development for task automation for civil engineers.
He is an expert in MATLAB and other professional engineering softwares such as
Autodesk Robot, Autodesk Revit, AutoCAD.
2.2 Services offered by Eng. Gouater Loic Dimitri
 Provides professional MATLAB codes and simulations for engineers in the
field civil, mechanical, and electrical engineering field.
 Develops detailed MATLAB codes for research Papers or Articles in
engineering that reproduces the exact results as stated in the document.
 Develops complete, simple, and flexible code package that can be used for
any research project that has to do with Self Recurrent Wavelet Neutral
Network (SRWNN).
 Code Verification and Enhancement in any research project in civil,
mechanical, and electrical engineering field
 Online training on software like Robot structural analysis, Autodesk Robot,
Autodesk Revit, AutoCAD, MATLAB.

2
CHAPTER THREE
ACTIVITIES CARRIED OUT BY THE INTERN
At the beginning of the internship, I was given a MATLAB book entitled
MATLAB A Practical Introduction to Programming and Problem Solving by
Stormy Attaway. I was guided on how to read the book and while reading the
book, I came across several exercises and practical question in the book to be
applied in MATLAB from every chapter of the book. The first five chapters are
the basics and fundamentals to introduce students to MATLAB. These five
chapters are: 1-Introduction to MATLAB, 2-Vectors and Matrices, 3- Introduction
to MATLAB Programming, 4-Selection Statements and 5-Loop Statements and
Vectorizing Code.

After going through the first five chapters and answering all their exercises, my
answers were corrected by the MATLAB expert, and from there I was good to
start my internship project which aligns with my civil engineering domain.
Throughout the project, I was always encourage by the Expert to write the code on
my own in order for me to develop analytical skills and for me to be able to use
the knowledge I had to be working throughout the project and the Expert could
intervein only when I have tried and did the best I could and from there he will
help me figure the things out at the point and give me guiding informations on
how I should proceed in the project.

The Project was “Creating an application in MATLAB that takes as input the
values of the loads and the length of the beam and model this beam and loads
on a MATLAB interface and calculate the shear and moment forces of the
loads, then draw their respective shear and moment diagrams on the beam”.
I named my application Steel Beam Designer. In order to create this application,
the work was divided into several tasks as follows.

3
3.1 Tasks Accomplished by the Intern during the Project:
Task 1: Creating the Application Interface in MATLAB

The first task was to create the interface of the application in MATLAB. Then
after I divided the interface into three major parts which are called “panels” in
MATLAB. These panels are the Option, Graphics, Display panels. There is also a
Tool panels which placed in the graphics panel. To perform that task, I wrote the
code, and the result is as follows:

4
Task 2: Creating the pop-up Menu and Check boxes

After creating the interface, I focused on the Option panel which is the panel
where the user of the application will enter the values for the length which he
wants the beam to have and enter the values of the loads. In the option panel a
pop-up menu is created, and this pop-up menu is a list that contains Geometry,
Loading, Material, Support and Results. I have set by default that Geometry is the
first option on the option panel, beside the geometry is a drop-down button on
which when you click, then it pops-up the list. The Geometry is where the user
enters informations about the length of the beam that he wants to model, the
section type if it is rectangular or circular and then enters the different dimensions
of the cross section of that beam. I have placed an image to show to the user the
indications of the dimensions of the cross section

The Loading in the pop-up menu is the second in the list and it is where the user
choses the type of the load that is, if the load is point load, uniform, or trapezoidal
load and then the user enters the value of the load or loads if it is trapezoidal. The
user also enters here the position where the load should be on the beam. For
uniform and trapezoidal we also precise the span of the load.

5
The Material section is just to enter the Young Modulus, if necessary.

Support is where the user selects the type of support for the beam that is if it is a
simply supported beam or a cantilevered beam by clicking on the button
corresponding to the users choice. The swap is to change the position of the
support and send it to the opposite side

6
The Result is the last in the pop-up list and it is where the user clicks on the
compute button present under results, when the user clicks on compute the shear
force and moment are calculated, and all the option under the compute button are
enable and the user can click on the bending Moment button in order for the
bending moment diagram to be displayed on the Graphic panel and the user can
also click on the shear force button and the shear force diagram is displayed on the
Graphic panel.

For the Display panel, I created the check boxes for load, Support, Dimensions of
the beam, and Geometry, so that here when the user clicks on a check box and
that a tick appears in the check box the corresponding property is turn on and
displayed on the beam in graphics panel and when the un-checks or click for the

7
second time on the box to remove the tick, the corresponding property value is
turn off and no more displayed on the beam in the graphics panel.

After this I place the elements of the tool panel which are Open, save, Panoramic,
Zoom In, Zoom out, Cancel, and rotate which are mostly used in 3D modelling.
But for now I did just for the 2D modelling.

Task 3: Draw the Beam, Supports and place the dimension of the Beam

To draw the beam on the graphics panel, first thing is to create an axis on the
graphic panel and I created the axis using built in MATLAB functions. After to
draw the beam and to draw the supports, I drew them first on a piece of paper and
by so doing I could calculate the appropriate dimensions that my supports should
have when appearing on the graphics panel. To implement this supports
MATLAB, I wrote my own line of codes in MATLAB and create my function that
enables me to model the support and the beam dimension in the graphics panel. By
default I programmed the length of the beam to be three meters. After writing the
code launching the codes it produces the following results;

8
Task 4: Draw the load on the Beam and Label the Load

To draw the load on the beam, I first drew it on a paper in order to figure out how I
could create an algorithm to draw the load in MATLAB and making the loads of
larger magnitudes to be much larger on the beam than the loads of lower
magnitudes. Using the built in MATLAB function called patch, I could draw the
load on the beam. After writing the algorithm and drawing using the patch
function, the result is as follows; on the following diagram the first load is a point
load, the second is uniform and the third is trapezoidal load. The arrows indicate
the direction of the force. So the negative signs on the values of the loads are just
to indicate direction of the force.

Task 5: Collecting information Enter by the User and Enabling the Edit button

After the interface being created and the different uicontrols where the user enters
the data, then the next step was to collect the data that the user has entered, and
then use the data to fit it in the algorithm that I have written in order to calculate
the shear and moment forces and when the compute button is clicked , to draw the
shear and moment diagram when their respective buttons are clicked. I also had to

9
enable the button called “edit load” so that when the user clicks on a particular
load the “edit load” button is enabled and the “add load” button is disabled, the
load becomes red, then the user can change the magnitude, direction, and even the
position of the load on the beam and the user can delete the load if the user presses
the delete key on the keyboard.

When the user clicks on the load and that the load becomes red, the user can enter
new value in the box “a” which is to change the position of the load along the
beam or the user can change the magnitude of the load in the box “P” and to
change the direction of the load, the user just has to change the sign of the new
magnitude. When the user changes the direction or magnitude of the load and goes
back to result and click on compute, the algorithm collects the new data and
calculates the forces, and the new shear and moment diagram can be drawn.

Task 6: Plotting the Shear and Moment diagram

After modelling everything, I used the concepts of applied mechanics and derived
manually the formulae that calculates; the reaction forces from the supports of the
beam, using that to derive a formula that calculates shear and moment forces.
From these formulae I developed algorithm to calculate the shear and moment
force for every load applied on the beam. From the results obtained, with the help
of the Expert, I could develop an algorithm to plot the shear force and moment
diagram. After writing the algorithm and running the code gives the following
result below with the red line for the shear diagram and the blue line for the
moment diagram.

10
Task 7: To create a pointer that appears when the mouse is placed on the shear or
moment diagram

The pointer appears indicating the Coordinate of the point where it is placed, and
the coordinates appears when the mouse moves on the diagram. I was directed by
the expert to use the MATLAB function “iptsetpointerBehaviour” to help me write
the algorithm in order to accomplish this task.

11
CHAPTER FOUR
CONCLUSION AND RECOMMENDATIONS
4.1 Challenges encounter by the Intern:
 I had difficulties in modelling the circular support in the simply supported beam
and drawing the line under the circular support.
 I had difficulties in using the shear force and moment values collected after
computing to draw the moment and shear force diagrams on the beam as shown
above.
 I had difficulties in creating a in the form of a plus sign that will display the
coordinate of the position where I place my mouse on the shear force or on the
moment diagram and that as the mouse is moving on the diagram, the pointer
continues to indicate the coordinates of the points as we move through those
pointts using the mouse.

4.2 Conclusions

The internship went on very well and it was a very nice experience to working on a
project with a MATLAB expert and seeing him supervising the work at each step and
always encouraging me to work on my own. At points where I had difficulties and
that I was stopped the Expert could now intervein and give me more details about
what I am supposed to do, then I could continue the project.

12
Appendix
Here is the Complete MATLAB codes of my application

function SteelBeamDesigner
clc; clear; close all;
figure('position',
[0,0,1000,500],'menubar','none','name','SteelBeamDesigner','numbertitle','o
ff',...

'DefaultUipanelUnits','pixels','DefaultAxesUnits','pixels','windowkeypressfcn'
,@EscapeKey)
movegui(gcf,'center')
panOpt = uipanel('title','Options','position',
[0,150,300,350],'backgroundcolor',[0.9,0.9,0.9]);
panDisp = uipanel('title','Display','position',[0,0,300,150],'backgroundcolor',
[0.9,0.9,0.9]);
panGraph = uipanel('title','Graphics','position',
[300,0,700,500],'backgroundcolor',[0.9,0.9,0.9]);
panTool = uipanel(panGraph,'bordertype','none','title','Tools','position',
[400,450,300,50],'backgroundcolor',[0.9,0.9,0.9]);

%% OPTIONS Panel
%% Geometry
popGeo = uicontrol(panOpt,'style','popupmenu','string',
{'GEOMETRY','LOADING','MATERIAL','SUPPORT','RESULTS'},'position',
[25,275,120,35],...

'fontsize',11,'fontweight','bold','callback',@ChangeProp,'backgroundcolor','w
');
%Length
uicontrol(panOpt,'style','text','string','Length: ','position',
[35,245,50,25],'fontweight','bold','tag','GEOMETRY')
etxtL = uicontrol(panOpt,'style','edit','string','3','position',
[85,245,50,23],'tag','GEOMETRY','userdata','3','callback',@BeamDraw);
uicontrol(panOpt,'style','text','string','m','position',
[135,245,20,25],'tag','GEOMETRY')
%Section Type

13
uicontrol(panOpt,'style','text','string','Section Type: ','position',
[35,210,85,25],'fontweight','bold','tag','GEOMETRY')
PopST = uicontrol(panOpt,'style','popupmenu','string',
{'Rectangular','Circular'},'position',[125,210,90,25],...
'callback',@ChangeSectype,'tag','GEOMETRY');
%Image
ST = uicontrol(panOpt,'position',[70,90,115,95],'cdata',imread('MATLAB\
RectangularST.PNG'),'foregroundcolor','b','tag','GEOMETRY');
%b
b = uicontrol(panOpt,'style','text','string','b: ','position',
[35,50,50,25],'fontweight','bold','tag','GEOMETRY');
uicontrol(panOpt,'style','edit','string','5','position',
[85,50,50,23],'tag','GEOMETRY');
uicontrol(panOpt,'style','text','string','cm','position',
[135,50,20,25],'tag','GEOMETRY')
%h
Strh = uicontrol(panOpt,'style','text','string','h: ','position',
[35,15,50,25],'fontweight','bold','tag','GEOMETRY');
Etxth = uicontrol(panOpt,'style','edit','string','10','position',
[85,15,50,23],'tag','GEOMETRY');
Uh = uicontrol(panOpt,'style','text','string','cm','position',
[135,15,20,25],'tag','GEOMETRY');

set(findobj('tag','GEOMETRY'),'backgroundcolor',get(panOpt,'backgroundc
olor'))

%% Loading
%Type
uicontrol(panOpt,'style','text','string','Type','position',
[35,245,50,25],'fontweight','bold','tag','LOADING','visible','off')
PopLdt = uicontrol(panOpt,'style','popupmenu','string',
{'Point','Uniform','Trapezoidal'},'position',[85,245,90,25],...
'tag','LOADING','visible','off','callback',@ChangeLoadType);
%We use the trapezoidal load interface and derive the two others from it
and set point load interface to appear first when we click on loading
im = uicontrol(panOpt,'position',[70,130,145,95],'cdata',imread('MATLAB\
TrapezoidalLD.PNG'),'tag','LOADING','visible','off');
%q1 for Trapezoidal Load
Strq1 = uicontrol(panOpt,'style','text','string','q1: ','position',
[15,90,50,25],'fontweight','bold','tag','LOADING','visible','off');

14
etxtP1 = uicontrol(panOpt,'style','edit','string','10','position',
[65,90,50,23],'tag','LOADING','visible','off','userdata','10','callback',@checkE
dit1);
Uq1 = uicontrol(panOpt,'style','text','string','KN/m','position',
[115,90,45,25],'tag','LOADING','visible','off');
%q2 for Trapezoidal Load
Strq2 = uicontrol(panOpt,'style','text','string','q2: ','position',
[165,90,30,25],'fontweight','bold','tag','LOADING','visible','off');
etxtP2 = uicontrol(panOpt,'style','edit','string','10','position',
[200,90,40,23],'tag','LOADING','visible','off','userdata','10','callback',@check
Edit1);
Uq2 = uicontrol(panOpt,'style','text','string','KN/m','position',
[240,90,45,25],'tag','LOADING','visible','off');
%a for Trapezoidal Load
uicontrol(panOpt,'style','text','string','a: ','position',
[15,55,50,25],'fontweight','bold','tag','LOADING','visible','off')
etxta = uicontrol(panOpt,'style','edit','string','0','position',
[65,55,50,23]','tag','LOADING','visible','off','userdata','0','callback',@checkE
dit2);
uicontrol(panOpt,'style','text','string','m','position',
[115,55,20,25],'tag','LOADING','visible','off')
%b for Trapezoidal Load
Strb = uicontrol(panOpt,'style','text','string','b: ','position',
[160,55,50,25],'fontweight','bold','tag','LOADING','visible','off');
etxtb = uicontrol(panOpt,'style','edit','string','0','position',
[200,55,50,23],'tag','LOADING','visible','off','userdata','0','callback',@checkE
dit2);
Ub = uicontrol(panOpt,'style','text','string','m','position',
[250,55,20,25],'tag','LOADING','visible','off');
%Edit and Add Load
% pbEdit
pbEdit = uicontrol(panOpt,'string','Edit Load','position',
[55,10,70,30],'fontweight','bold','tag','LOADING','visible','off',...
'enable','off','callback',@editLoad);
% pbAdd
pbAdd = uicontrol(panOpt,'string','Add Load','position',
[190,10,70,30],'fontweight','bold','tag','LOADING','visible','off','callback',@Ad
dLoad);

%% Material

15
% uicontrol(panOpt,'style','text','string','Young Modulus','position',
[35,205,150,30],'fontweight','bold','tag','MATERIAL','visible','off','fontsize',15
)
uicontrol(panOpt,'style','text','string','E:','position',
[35,150,50,30],'fontweight','bold','tag','MATERIAL','visible','off','fontsize',10)
uicontrol(panOpt,'style','edit','string','0','position',
[80,150,45,28],'fontweight','bold','tag','MATERIAL','visible','off')
uicontrol(panOpt,'style','text','string','GPa','position',
[125,150,60,30],'fontweight','bold','tag','MATERIAL','visible','off','fontsize',10
)

%% Support
RbS = uicontrol(panOpt,'style','radio','string','Simply Supported','position',
[35,200,140,30],'fontweight','bold','tag','SUPPORT',...
'visible','off','fontsize',10,'callback',@AddSimpleSup,'value',1);
RbC = uicontrol(panOpt,'style','radio','string','Cantilevered','position',
[35,165,130,30],'fontweight','bold','tag','SUPPORT',...
'visible','off','fontsize',10,'callback',@AddCantileverSup);
ckSwap = uicontrol(panOpt,'style','check','string','Swap','position',
[35,130,130,25],'fontweight','bold','tag','SUPPORT','visible',...
'off','fontsize',10,'callback',@SwapSides);

%% Results
uicontrol(panOpt,'string','Compute','position',
[50,235,80,30],'fontweight','bold',...
'tag','RESULTS','visible','off','fontsize',10,'callback',@compute)
uicontrol(panOpt,'style','check','string','Bending Moment','position',
[30,200,150,30],'fontweight','bold',...

'tag','RESULTS','visible','off','fontsize',10,'enable','off','callback',@plotIntern
alForces)
uicontrol(panOpt,'style','check','string','Shear Force','position',
[30,160,150,30],'fontweight','bold',...

'tag','RESULTS','visible','off','fontsize',10,'enable','off','callback',@plotIntern
alForces)
uicontrol(panOpt,'style','check','string','Axial Force','position',
[30,120,150,30],'fontweight','bold',...
'tag','RESULTS','visible','off','fontsize',10,'enable','off')

16
uicontrol(panOpt,'style','check','string','Deflection','position',
[30,80,100,30],'fontweight','bold',...
'tag','RESULTS','visible','off','fontsize',10,'enable','off')
uicontrol(panOpt,'string','Export to PDF','position',
[30,30,150,30],'fontweight','bold',...
'tag','RESULTS','visible','off','fontsize',10,'enable','off')

%% Display Panel
uicontrol(panDisp,'style','check','string','Geometry','position',
[35,80,90,30],'fontweight','bold','fontsize',10,...

'backgroundcolor',get(panDisp,'backgroundcolor'),'callback',@DispSupps)
uicontrol(panDisp,'style','check','string','Supports','position',
[35,35,90,30],'fontweight','bold','fontsize',10,...

'backgroundcolor',get(panDisp,'backgroundcolor'),'callback',@DispSupps,'v
alue',1)
uicontrol(panDisp,'style','check','string','Load','position',
[170,80,90,30],'fontweight','bold','fontsize',10,...

'backgroundcolor',get(panDisp,'backgroundcolor'),'callback',@DispSupps,'v
alue',1)
uicontrol(panDisp,'style','check','string','Dimensions','position',
[170,35,100,30],'fontweight','bold','fontsize',10,...

'backgroundcolor',get(panDisp,'backgroundcolor'),'callback',@DispSupps,'v
alue',1)

%% Tools Panel
uicontrol(panTool,'position',
[20,7,27,26],'tooltip','OPEN','cdata',imread('MATLAB\Open.PNG'))
uicontrol(panTool,'position',
[60,7,27,25],'tooltip','SAVE','cdata',imread('MATLAB\Save.PNG'))
uicontrol(panTool,'position',
[100,7,27,25],'tooltip','PANORAMIC','cdata',imread('MATLAB\
Panoramic.PNG'))
uicontrol(panTool,'position',[140,7,27,25],'tooltip','ZOOM
IN','cdata',imread('MATLAB\Zoom In.PNG'))
uicontrol(panTool,'position',[180,7,27,25],'tooltip','ZOOM
OUT','cdata',imread('MATLAB\Zoom Out.PNG'))

17
uicontrol(panTool,'position',[220,7,27,25],'tooltip','CANCEL
ALL','cdata',imread('MATLAB\Cancel All.PNG'))
uicontrol(panTool,'position',[260,7,28,25],'tooltip','ROTATE
3D','cdata',imread('MATLAB\Rotate 3D.PNG'))

%% Axes, Graphics Panel


ax1 = axes('parent',panGraph,'position',
[5,5,690,440],'visible','off','nextplot','add');
axis equal
Ln = line([0,3],[0,0],'linewidth',3,'color','b');
TriangularBeamSup([0,0],3)
CircularBeamSup([3,0],3)

%% Data
global data;
data.load = {}; %it has just two columns {[1st col],[2nd col]}
%and it stores {1st column = load props(that is [type, Mag, Position]),
%2nd column = Graphics(that is [graphic obj, graphics text])}
data.results = [];
Pmax = 0;
Mmax = 0;
Vmax=0;
len = str2double(get(etxtL,'string'));

%% CALLBACKS

function ChangeProp(~,~)
set(pbEdit,'enable','off')
hn = get(popGeo,'string');
val = get(popGeo,'value');

set(findobj('tag',hn{val}),'backgroundcolor',get(panOpt,'backgroundcolor'))
if val == 1 %when we are in Geometry
set(findobj('tag',hn{val}),'visible','on')
set(findobj('tag',hn{2}),'visible','off')
set(findobj('tag',hn{3}),'visible','off')
set(findobj('tag',hn{4}),'visible','off')
set(findobj('tag',hn{5}),'visible','off')
set(PopST,'value',1)
set(ST,'cdata',imread('MATLAB\RectangularST.PNG'))
set(b,'string','b:')

18
set(Strh,'visible','on')
set(Etxth,'visible','on')
set(Uh,'visible','on')
elseif val == 2 %when we click on Loading
set(findobj('tag',hn{val}),'visible','on')
set(findobj('tag',hn{1}),'visible','off')
set(findobj('tag',hn{3}),'visible','off')
set(findobj('tag',hn{4}),'visible','off')
set(findobj('tag',hn{5}),'visible','off')
% for Point load props to appear first
set(im,'cdata',imread('MATLAB\PointLD.PNG'))
set(Strq1,'string','P:')
set(Uq1,'string','KN')
set(Strq2,'visible','off')
set(etxtP2,'visible','off')
set(Uq2,'visible','off')
set(Strb,'visible','off')
set(etxtb,'visible','off')
set(Ub,'visible','off')
set(PopLdt,'value',1)
elseif val == 3 %when we click on Material
set(findobj('tag',hn{val}),'visible','on')
set(findobj('tag',hn{1}),'visible','off')
set(findobj('tag',hn{2}),'visible','off')
set(findobj('tag',hn{4}),'visible','off')
set(findobj('tag',hn{5}),'visible','off')
elseif val == 4 %when we click on Support
set(findobj('tag',hn{val}),'visible','on')
set(findobj('tag',hn{1}),'visible','off')
set(findobj('tag',hn{2}),'visible','off')
set(findobj('tag',hn{3}),'visible','off')
set(findobj('tag',hn{5}),'visible','off')
elseif val == 5 %when we click on Results
set(findobj('tag',hn{val}),'visible','on')
set(findobj('tag',hn{1}),'visible','off')
set(findobj('tag',hn{2}),'visible','off')
set(findobj('tag',hn{3}),'visible','off')
set(findobj('tag',hn{4}),'visible','off')
end
end

19
function ChangeSectype(src,~)
val = get(src,'value');
if val == 1 %Rectangular
set(ST,'cdata',imread('MATLAB\RectangularST.PNG'))
set(b,'string','b:')
set(Strh,'visible','on')
set(Etxth,'visible','on')
set(Uh,'visible','on')
elseif val == 2 %Circular
set(ST,'cdata',imread('MATLAB\CircularST.PNG'))
set(b,'string','r :','fontsize',10)
set(Strh,'visible','off')
set(Etxth,'visible','off')
set(Uh,'visible','off')
end
end

function ChangeLoadType(src,~)
val = get(src,'value');
set(pbEdit,'enable','off')
if val == 1 %Point load
set(im,'cdata',imread('MATLAB\PointLD.PNG'))
set(Strq1,'string','P:')
set(Uq1,'string','KN')
set(Strq2,'visible','off')
set(etxtP2,'visible','off')
set(Uq2,'visible','off')
set(Strb,'visible','off')
set(etxtb,'visible','off')
set(Ub,'visible','off')
elseif val == 2 %For Uniform Load
set(im,'cdata',imread('MATLAB\UniformLD.PNG'))
set(Strq1,'string','q:')
set(Strq2,'visible','off')
set(etxtP2,'visible','off')
set(Uq2,'visible','off')
set(Strb,'visible','on')
set(etxtb,'visible','on')
set(Ub,'visible','on')

20
elseif val == 3 %For Trapezoidal Load
set(im,'cdata',imread('MATLAB\TrapezoidalLD.PNG'))
set(Strq1,'string','q1:')
set(Strb,'visible','on')
set(etxtb,'visible','on')
set(Ub,'visible','on')
set(Strq2,'visible','on')
set(etxtP2,'visible','on')
set(Uq2,'visible','on')
end
end

function AddSimpleSup(src,~)
val = get(src,'value');
if val == 1 % Simple support activates
set(RbC,'value',0)
BeamDraw
else % Cantilever support activates
set(RbC,'value',1)
BeamDraw
end
end

function AddCantileverSup(src,~)
val = get(src,'value');
if val == 1 % Cantilever support activate
set(RbS,'value',0)
BeamDraw
else % Simple support activates
set(RbS,'value',1)
BeamDraw
end
end

function TriangularBeamSup(Pt,L)
%Pt are starting point for the triangle which is in the form (x,y)
a = 0.2*L/4;
%Simple Supported
coord = [Pt;Pt(1)+a/4,Pt(2)-a/2;Pt(1)-a/4,Pt(2)-a/2];
con = [1,2,3];

21
patch('vertices',coord,'faces',con,'facecolor','r','tag','Supports')
line([0,L],[-3*a,-3*a],'marker','*','markersize',10,'tag','Dimensions')
text(L/2,-3*a,[num2str(L), '
m'],'verticalalignment','bottom','tag','Dimensions')
end

function CircularBeamSup(Pt,L)
r = 0.1*L/8; %r = radius
x_cen = Pt(1); %x_cen = x_center
y_cen = Pt(2) - 0.115*L/8; %to place the support at the ending
extreme of the Beam
t = 0:pi/50:2*pi;
X = r*cos(t)+x_cen;
Y = r*sin(t)+y_cen;
patch(X,Y,'red','tag','Supports')
%line below the circle
a = 0.1*L/4;
bL = 2*y_cen;
coord = [Pt(1),Pt(2)+bL;Pt(1)-a,Pt(2)+bL;Pt(1)+a,Pt(2)+bL];
con = [1,2;1,3];
patch('vertices',coord,'faces',con,'tag','Supports')
end

function CantileverBeamSup(Pt,L)
a = 0.2*L/4;
%Cantilever Support
coord =
[Pt;Pt(1),Pt(2)-a;Pt(1)-a/2,Pt(2)-a;Pt(1)-a/2,Pt(2)+a;Pt(1),Pt(2)+a;Pt];
con = [1,2;2,3;3,4;4,5;5,1];
patch('vertices',coord,'faces',con,'edgecolor','r','tag','Supports')
line([0,L],[-3*a,-3*a],'marker','*','markersize',10,'tag','Dimensions')
text(L/2,-3*a,[num2str(L), '
m'],'verticalalignment','bottom','tag','Dimensions')
end

function BeamDraw(~,~)
len = str2double(get(etxtL,'string'));
if isnan(len) == 0 && len > 0
set(Ln,'xdata',[0,len],'ydata',[0,0])
updateLoads

22
delete(findobj('tag','Supports'))
delete(findobj('tag','Dimensions'))
val = get(RbS,'value'); %Radio button Simple Supp = RbS
if val == 1 %Simple Supp is activated
TriangularBeamSup([0,0],len)
CircularBeamSup([len,0],len)
SwapSides
elseif val == 0 %val == 0 Cantilever Supp is activated
CantileverBeamSup([0,0],len)
SwapSides
end
set(etxtL,'userdata',len)
else
set(etxtL,'string',get(etxtL,'userdata')) %to make the value of
length get back to the previous correct value
end

end

function checkEdit1(src,~)
val = str2double(get(src,'string'));
pval = get(PopLdt,'value');
if isnan(val) || ~isreal(val) || isinf(val)
set(src,'string',get(src,'userdata'))
elseif pval ~= 3
if val == 0
set(src,'string',get(src,'userdata'))
end
else
set(src,'userdata',num2str(val))
end
end

function checkEdit2(src,~)
val = str2double(get(src,'string'));
a = str2double(get(etxta,'string'));
b1 = str2double(get(etxtb,'string'));
pval = get(PopLdt,'value');
if isnan(val) || (val < 0 || val > len)...
|| ~isreal(val) || isinf(val)

23
set(src,'string',get(src,'userdata'))
elseif pval ~= 1
if plus(a,b1) > len
set(src,'string',get(src,'userdata'))
end
else
set(src,'userdata',num2str(val))
end
end

function X = interpole(P)
C = len/10;
X = C*(1-(Pmax-abs(P))/Pmax)*-sign(P);
end

function X = interpolePltBM(M)
C = len/5;
X = C*(1-(Mmax-abs(M))/Mmax)*sign(M);
end

function X = interpolePltSF(V)
C = 0.05*len;
X = C*(1-(Vmax-abs(V))/Vmax)*sign(V);
end

function updateLoads
for i = 1: size(data.load,1) %this means going row by
row in data.load
delete(data.load{i,2}); %this means we should
delete the load but we use its graghic handle to delete it
DrawLoad(data.load{i,1},i)
end
end

function AddLoad(~,~)
set(pbEdit,'enable','off')
Loadtype = get(PopLdt,'value');
P = str2double(get(etxtP1,'string'));
a = str2double(get(etxta,'string'));
switch Loadtype
case 1 % Point Load

24
if abs(P) > Pmax
Pmax = abs(P);
updateLoads
end
data.load{end+1,1} = [1,P,a];

case 2 % Uniform Load


b1 = str2double(get(etxtb,'string'));
if abs(P) > Pmax
Pmax = abs(P);
updateLoads
end
data.load{end+1,1} = [2,P,a,b1];

case 3 % Trapezoidal Load


b1 = str2double(get(etxtb,'string'));
P2 = str2double(get(etxtP2,'string'));
Mx = max(abs([P,P2]));
if abs(Mx) > Pmax
Pmax = abs(Mx);
updateLoads
end
data.load{end+1,1} = [3,P,P2,a,b1];
end
if size(data.load,1) == 1 %to mean that when there is one
load on a Beam, its Mag becomes Pmax
switch data.load{1,1}(1)
case 1
Pmax = abs(data.load{1,1}(2));
case 2
Pmax = abs(data.load{1,1}(2));
case 3
Pmax = max(abs([data.load{1,1}(2),data.load{1,1}(3)]));
end
end
DrawLoad(data.load{end,1},size(data.load,1))
end

function DrawLoad(load,ind)

25
% ind is to identify the row of the particular load, we identify that row in
data.load
p = interpole(load(2));
a = p/5;
switch load(1)
case 1 % Point Load
coord = [load(3),0;load(3)-a/2,a;load(3)+a/2,a;load(3),p];
con = [1,2;1,3;1,4];
obj =
patch('vertices',coord,'faces',con,'buttondownfcn',@loadClick,'userdata',ind,
...
'edgecolor','k','tag','Load');
objTxt = text(load(3),p,[num2str(load(2)),'
kN'],'HorizontalAlignment','center','tag','Load',...
'buttondownfcn',@loadClick,'userdata',ind,'color','k');
if load(2)<0
set(objTxt,'VerticalAlignment','bottom')
else
set(objTxt,'VerticalAlignment','top')
end
data.load{ind,2} = [obj,objTxt];

case 2 % Uniform Load


ptA = [load(3),0];
ptB = [load(3)+load(4),0]; %here load(4) is my b
C = load(4)/4;
coord = [ptA;ptA(1)-a/2,a;ptA(1)+a/2,a;ptA(1),p;...
ptA(1)+C,ptA(2);ptA(1)+C-a/2,a;ptA(1)+C+a/2,a;ptA(1)+C,p;...

ptA(1)+2*C,ptA(2);ptA(1)+2*C-a/2,a;ptA(1)+2*C+a/2,a;ptA(1)+2*C,p;...

ptA(1)+3*C,ptA(2);ptA(1)+3*C-a/2,a;ptA(1)+3*C+a/2,a;ptA(1)+3*C,p;...
ptB;ptB(1)-a/2,a;ptB(1)+a/2,a;ptB(1),p];
con =
[1,2;1,3;1,4;5,6;5,7;5,8;9,10;9,11;9,12;13,14;13,15;13,16;17,18;17,19;17,20
;4,20];
obj = patch('vertices',coord,'faces',con,...

'buttondownfcn',@loadClick,'userdata',ind,'edgecolor','k','tag','Load');

26
objTxt = text(load(3)+2*C,p,[num2str(load(2)),'
kN'],'HorizontalAlignment','center','tag','Load',...
'buttondownfcn',@loadClick,'userdata',ind,'color','k');
if load(2)<0
set(objTxt,'VerticalAlignment','bottom')
else
set(objTxt,'VerticalAlignment','top')
end
data.load{ind,2} = [obj,objTxt];

case 3 % Trapezoidal Load


p2 = interpole(load(3)); %here load(3) is my p2 or
q2
ptA = [load(4),0]; %here load(4) is my a and
load(5) is my b
ptB = [load(4)+load(5),0];
C = load(5)/4;
if abs(load(3)) > abs(load(2))
D = (p2 - p)/4;
a = p2/5;
coord = [ptA;ptA(1)-a/2,(p)/4;ptA(1)+a/2,(p)/4;ptA(1),p;...

ptA(1)+C,ptA(2);ptA(1)+C-a/2,(p+D)/4;ptA(1)+C+a/2,(p+D)/4;ptA(1)+C,p+D;
...

ptA(1)+2*C,ptA(2);ptA(1)+2*C-a/2,(p+2*D)/4;ptA(1)+2*C+a/2,(p+2*D)/
4;ptA(1)+2*C,p+2*D;...

ptA(1)+3*C,ptA(2);ptA(1)+3*C-a/2,(p+3*D)/4;ptA(1)+3*C+a/2,(p+3*D)/
4;ptA(1)+3*C,p+3*D;...
ptB;ptB(1)-a/2,(p2)/5;ptB(1)+a/2,(p2)/5;ptB(1),p2;];
%The Y-values of each points are made to correspond the
magnitude of the load
con =
[1,2;1,3;1,4;5,6;5,7;5,8;9,10;9,11;9,12;13,14;13,15;13,16;17,18;17,19;17,20
;4,20];
elseif abs(load(3)) < abs(load(2))
D = (p - p2)/4;
coord = [ptA;ptA(1)-a/2,(p)/5;ptA(1)+a/2,(p)/5;ptA(1),p;...

ptA(1)+C,ptA(2);ptA(1)+C-a/2,(p-D)/4;ptA(1)+C+a/2,(p-D)/4;ptA(1)+C,p-D;...

27
ptA(1)+2*C,ptA(2);ptA(1)+2*C-a/2,(p-2*D)/4;ptA(1)+2*C+a/2,(p-2*D)/
4;ptA(1)+2*C,p-2*D;...

ptA(1)+3*C,ptA(2);ptA(1)+3*C-a/2,(p-3*D)/4;ptA(1)+3*C+a/2,(p-3*D)/
4;ptA(1)+3*C,p-3*D;...
ptB;ptB(1)-a/2,(p2)/4;ptB(1)+a/2,(p2)/4;ptB(1),p2];
con =
[1,2;1,3;1,4;5,6;5,7;5,8;9,10;9,11;9,12;13,14;13,15;13,16;17,18;17,19;17,20
;4,20];
elseif (abs(load(3)) == abs(load(2))) && (sign(load(2)) == -1 ||
sign(load(3)) == -1) && (sign(load(2)) ~= sign(load(3)))
D = p/2;
D1 = p2/2;
coord = [ptA(1),ptA(2);ptA(1)-a/2,a;ptA(1)+a/2,a;ptA(1),p;...
ptA(1)+C,ptA(2);ptA(1)+C-a/2,a;ptA(1)+C+a/2,a;ptA(1)+C,p-
D;...
ptB(1)-C,-ptB(2);ptB(1)-C-a/2,-a;ptB(1)-C+a/2,-a;ptB(1)-
C,p2-D1;...
ptB(1),-ptB(2);ptB(1)-a/2,-a;ptB(1)+a/2,-a;ptB(1),p2];
con =
[1,2;1,3;1,4;5,6;5,7;5,8;9,10;9,11;9,12;13,14;13,15;13,16;4,16];
elseif abs(load(3)) == abs(load(2))
coord = [ptA;ptA(1)-a/2,a;ptA(1)+a/2,a;ptA(1),p;...

ptA(1)+C,ptA(2);ptA(1)+C-a/2,a;ptA(1)+C+a/2,a;ptA(1)+C,p;...

ptA(1)+2*C,ptA(2);ptA(1)+2*C-a/2,a;ptA(1)+2*C+a/2,a;ptA(1)+2*C,p;...

ptA(1)+3*C,ptA(2);ptA(1)+3*C-a/2,a;ptA(1)+3*C+a/2,a;ptA(1)+3*C,p;...
ptB;ptB(1)-a/2,a;ptB(1)+a/2,a;ptB(1),p2];
con =
[1,2;1,3;1,4;5,6;5,7;5,8;9,10;9,11;9,12;13,14;13,15;13,16;17,18;17,19;17,20
;4,20];
end

obj = patch('vertices',coord,'faces',con,
'buttondownfcn',@loadClick,'userdata',ind,...
'edgecolor','k','tag','Load');
objTxt1 = text(ptA(1),p,[num2str(load(2)),'
kN'],'HorizontalAlignment','right','tag','Load',...

28
'buttondownfcn',@loadClick,'userdata',ind,'color','k');
objTxt2 = text(ptB(1),p2,[num2str(load(3)),'
kN'],'HorizontalAlignment','left','tag','Load',...
'buttondownfcn',@loadClick,'userdata',ind,'color','k');
if load(2)<0
set(objTxt1,'VerticalAlignment','bottom')
else
set(objTxt1,'VerticalAlignment','top')
end
if load(3)<0
set(objTxt2,'VerticalAlignment','bottom')
else
set(objTxt2,'VerticalAlignment','top')
end
data.load{ind,2} = [obj,objTxt1,objTxt2];
end
end

function loadClick(src,~)
set(pbAdd,'enable','off')
% change all loads to black
set(findobj('tag','Load','type','patch'),'edgecolor','k')
set(findobj('tag','Load','type','text'),'color','k')
% change load selected to red
ind = get(src,'userdata'); %ind indicates the row
where the load we have selected is found
obj = data.load{ind,2}(1);
objTxt = data.load{ind,2}(2);
set(obj,'edgecolor','r');
set(objTxt,'color','r');
if length(data.load{ind,2}) == 3 %we use this to make all
the loads text in trapezoidal load red
objTxt1 = data.load{ind,2}(2);
objTxt2 = data.load{ind,2}(3);
set(objTxt1,'color','r');
set(objTxt2,'color','r');
end

% GUI
set(popGeo,'value',2)

29
ChangeProp
set(PopLdt,'value',data.load{ind,1}(1))
ChangeLoadType(PopLdt)
switch data.load{ind,1}(1)
case 1 %Point Load
set(etxtP1,'string',num2str(data.load{ind,1}(2)))
set(etxta,'string',num2str(data.load{ind,1}(3)))
case 2 %Uniform Load
set(etxtP1,'string',num2str(data.load{ind,1}(2)))
set(etxta,'string',num2str(data.load{ind,1}(3)))
set(etxtb,'string',num2str(data.load{ind,1}(4)))
case 3 %Trapezoidal Load
set(etxtP1,'string',num2str(data.load{ind,1}(2)))
set(etxtP2,'string',num2str(data.load{ind,1}(3)))
set(etxta,'string',num2str(data.load{ind,1}(4)))
set(etxtb,'string',num2str(data.load{ind,1}(5)))
end
set(pbEdit,'enable','on')
end

function editLoad(~,~)
ind = get(findobj('tag','Load','edgecolor','r'),'userdata');
switch data.load{ind,1}(1)
case 1 %Point Load
P = str2double(get(etxtP1,'string'));
a = str2double(get(etxta,'string'));
if abs(P) > Pmax
Pmax = abs(P);
updateLoads
end
data.load{ind,1} = [1 P a];
case 2 %Uniform Load
P = str2double(get(etxtP1,'string'));
a = str2double(get(etxta,'string'));
b1 = str2double(get(etxtb,'string'));
if abs(P) > Pmax
Pmax = abs(P);
updateLoads
end
data.load{ind,1} = [2,P,a,b1];

30
case 3 %Trapezoidal Load
P = str2double(get(etxtP1,'string'));
P2 = str2double(get(etxtP2,'string'));
a = str2double(get(etxta,'string'));
b1 = str2double(get(etxtb,'string'));
Mx = max(abs([P,P2]));
if abs(Mx) > Pmax
Pmax = abs(Mx);
updateLoads
end
data.load{ind,1} = [3,P,P2,a,b1];
end
delete(data.load{ind,2})
if size(data.load,1) == 1 %to mean that when there is one
load on a Beam, its Mag becomes Pmax
switch data.load{1,1}(1)
case 1
Pmax = abs(data.load{1,1}(2));
case 2
Pmax = abs(data.load{1,1}(2));
case 3
Pmax = max(abs([data.load{1,1}(2),data.load{1,1}(3)]));
end
end
DrawLoad(data.load{ind,1},ind)
set(data.load{ind,2}(1),'edgecolor','r');
set(data.load{ind,2}(2),'color','r');
if length(data.load{ind,2}) == 3 %we use this to make all
the loads text in trapezoidal load red
objTxt1 = data.load{ind,2}(2);
objTxt2 = data.load{ind,2}(3);
set(objTxt1,'color','r');
set(objTxt2,'color','r');
end
end

function DispSupps(src,~)
hn = get(src,'string');
val = get(src,'value');

31
if val == 1
set(findobj('tag',hn),'visible','on')
else
set(findobj('tag',hn),'visible','off')
end
end

function SwapSides(~,~)
valSwp = get(ckSwap,'value'); %valSwp means value of the
Swap
delete(findobj('tag','Supports'))
L = str2double(get(etxtL,'string'));
a = 0.2*L/4;
val = get(RbS,'value'); %Radio button Simple Supp = RbS
if valSwp == 1
if val == 1
TriangularBeamSup([L,0],L)
CircularBeamSup([0,0],L)
elseif val == 0
CantileverBeamSup([L+(a/2),0],L)
end
elseif valSwp == 0 %val == 0 means value of the Swap
if val == 1
TriangularBeamSup([0,0],L)
CircularBeamSup([L,0],L)
elseif val == 0
CantileverBeamSup([0,0],L)
end
end

end

function EscapeKey(~,evnt)
if strcmp(evnt.Key,'escape')
set(findobj('tag','Load','type','patch'),'edgecolor','k')
set(findobj('tag','Load','type','text'),'color','k')
set(pbEdit,'enable','off')
elseif strcmp(evnt.Key,'delete')
ind = get(findobj('tag','Load','edgecolor','r'),'userdata');
delete(data.load{ind,2});

32
for i = ind+1:length(data.load)
Robj = findobj('tag','Load','edgecolor','k','userdata',i);
%Robj means the remaining objects after deleting the others
RobjTxt = findobj('tag','Load','color','k','userdata',i);
set(Robj,'userdata',i-1)
set(RobjTxt,'userdata',i-1)
end
data.load = data.load([1:ind-1,ind+1:end],:);
set(pbEdit,'enable','off')
end
set(pbAdd,'enable','on')
end

function plotInternalForces(src,~)
val = get(src,'value');
hn = get(src,'string');
if val == 1
switch hn
case 'Bending Moment'

plot(ax1,data.results.x,data.results.M(data.results.x),'tag','moment','color','b'
);
case 'Shear Force'
for i = 1:size(data.load,1)
switch data.load{1}(1)
case 1 %point load

plot(ax1,data.results.xV,data.results.V(data.results.xV),'tag','shear','color','r'
);
case 2 %uniform load

plot(ax1,data.results.x,data.results.V(data.results.x),'tag','shear','color','r');
case 3 %Trapezoidal load

plot(ax1,data.results.x,data.results.V(data.results.x),'tag','shear','color','r');
end
end
case 'Axial Force'
case 'Deflection'
end
else

33
switch hn
case 'Bending Moment'
delete(findobj('tag','moment'))
case 'Shear Force'
delete(findobj('tag','shear'))
case 'Axial Force'
case 'Deflection'
end
end

pointerBehaviour.enterFcn = @(h, currentPoint)...


set(h, 'Pointer', 'cross');
pointerBehaviour.traverseFcn = @IndPosi;
pointerBehaviour.exitFcn = @deltUc;
iptSetPointerBehavior(findobj('tag','moment'),pointerBehaviour);
iptSetPointerBehavior(findobj('tag','shear'),pointerBehaviour);
iptPointerManager(gcf);
end

function IndPosi(~,~)
set(gcf,'name','inPatch')
set(gcf,'windowbuttonmotionfcn',@indPos)
delete(findobj('tag','uicontr','type','uicontrol'))
end

function indPos(~,~)
h = get(gcf,'name');
if strcmp(h,'inPatch')
cp = get(gca,'currentpoint');
cp = cp(1,1:2);
Xcord = num2str(cp(1,1));
if length(Xcord) > 4
Xcord = Xcord(1:4);
end
Ycord = num2str(cp(1,2));
Ycord = Ycord(1:4);
delete(findobj('tag','uicontr','type','text'))
text(0.05+cp(1,1),-0.05+cp(1,2),[Xcord,' ',Ycord],'tag','uicontr')
end
end

34
function deltUc(~,~)
set(gcf,'name','SteelBeamDesignerEmma2')
delete(findobj('tag','uicontr','type','text'))
end

function compute(~,~)
V = @(x) 0;
M = @(x) 0;
x = linspace(0,len,10);
xV = linspace(0,len,10);
for i = 1:size(data.load,1)
M = @(x) M(x) + bendingMoment(data.load{i,1},x);
V = @(x) V(x) + shearForce(data.load{i,1},x);

switch data.load{i,1}(1)
case 1 %Point load
x = unique([x data.load{i,1}(3)]);
if length(find(data.load{i,1}(3) == xV)) ~= 2
if any(data.load{i,1}(3) == xV)
xV = [xV(xV<=data.load{i,1}(3)) data.load{i,1}(3)...
xV(xV>data.load{i,1}(3))];
else
xV = [xV(xV<data.load{i,1}(3)) data.load{i,1}(3)...
data.load{i,1}(3) xV(xV>data.load{i,1}(3))];
end
end
case 2 %uniform Load
x = unique([x data.load{i,1}(3) data.load{i,1}(3)+data.load{i,1}
(4)/2 data.load{i,1}(3)+data.load{i,1}(4)]);
case 3 %Trapezoidal Load
x = unique([x data.load{i,1}(4) data.load{i,1}(5)*(data.load{i,1}
(3)+2*data.load{i,1}(2))/(3*(data.load{i,1}(2)+data.load{i,1}(3)))
data.load{i,1}(4)+data.load{i,1}(5)]);

end
end
data.results.M = M;
data.results.V = V;
data.results.x = x;

35
data.results.xV = xV;
set(findobj('tag','RESULTS','type','uicontrol'),'enable','on')
end

function M = bendingMoment(load,x)
%load = [type,magnitude,positions]
if size(data.load,1) == 1 %this means if there is one load on a Beam,
its mag will becomes Mmax
Mmax = 0;
end
rB = get(RbS,'value');
switch rB
case 1 %Case the loads are placed on a Simple Support
switch load(1)
case 1 % Point Load
M = zeros(1,length(x));
M(x<=load(3)) = load(2)*(len-load(3))*x(x<=load(3))/len;
M(x>load(3)) = load(2)*load(3)*(len-x(x>load(3)))/len;
case 2 % Uniform Load
M = zeros(1,length(x));
Rb = (load(2)*load(4)*(3*load(3)+load(4))
+load(2)*load(4)*(3*load(3)+2*load(4)))/(6*len);
Ra = (load(2)+load(2))*load(4)/2 - Rb;
m = 0;
n = load(2);
r = n/6 + load(2)/3;
M(x<=load(3)) = Ra*x(x<=load(3));
M(x<load(3)+load(4) - x<load(3)) =
(-m/6).*x(x<load(3)+load(4) - x<load(3)).^3 +...
(load(3)*(m/3)-r).*x(x<load(3)+load(4) - x<load(3)).^2 +...
(Ra+2*load(3)*r-m*load(3)^2/6).*x(x<load(3)+load(4) -
x<load(3)) - load(3)^2*r;
M(x>=load(3)+load(4)) = -Rb.*x(x>=load(3)+load(4)) +
Rb*len;
if len - str2double(get(etxta,'string')) <= 1
M(1) = interpolePltSF(interpolePltSF(M(1)));
M(2) = interpolePltSF(interpolePltSF(M(2)));
M(3) = interpolePltSF(interpolePltSF(M(3)));
M(4) = interpolePltSF(interpolePltSF(M(4)));
end

36
case 3 % Trapezoidal Load
M = zeros(1,length(x));
Rb = (load(2)*load(5)*(3*load(4)+load(5))
+load(3)*load(5)*(3*load(4)+2*load(5)))/(6*len);
Ra = (load(3)+load(2))*load(5)/2 - Rb;
m = (load(3)-load(2))/load(5);
n = load(2)-(load(3)-load(2))*load(4)/load(5);
r = n/6 + load(2)/3;
M(x<=load(4)) = Ra*x(x<=load(4));
M(x<load(4)+load(5) - x<load(4)) =
(-m/6).*x(x<load(4)+load(5) - x<load(4)).^3 +...
(load(3)*(m/3)-r).*x(x<load(4)+load(5) - x<load(4)).^2 +...
(Ra+2*load(4)*r-m*load(4)^2/6).*x(x<load(4)+load(5) -
x<load(4)) - load(4)^2*r;
M(x>=load(4)+load(5)) = -Rb.*x(x>=load(4)+load(5)) +
Rb*len;

end
if abs(max(M)) > Mmax
Mmax = abs(max(M));
end
for i = 1:length(M)
M(i) = interpolePltBM(M(i));
end

case 0 %Case the loads are placed on a Cantilevered Support


switch load(1)
case 1 %Point Load
M = zeros(1,length(x));
M(x<=load(3)) = -load(2)*x(x<=load(3)) + load(2)*load(3);
M(x>load(3)) = 0;
case 2 %Uniform Load
M = zeros(1,length(x));
Ry = load(2)*load(4);
Ma = load(2)*load(4)*(2*load(3)+load(4))/2 ;
m = 0;
n = load(2);
M(x<=load(3)) = Ma-Ry*x(x<=load(3));

37
M(x< load(3)+load(4) - x > load(3)) = (m/6).*x(x<
load(3)+load(4) - x > load(3)).^3 +...
(load(2)-load(3)*m/3+n).*x(x< load(3)+load(4) - x >
load(3)).^2+...
((load(3)^2)*m/6-Ry-load(2)*load(3)-2*load(3)*n).*x(x<
load(3)+load(4) - x > load(3)) +...
Ma+(load(2)*load(3)^2)/2+(load(3)^2)*n;
M(x>= load(3)+load(4)) = 0;
case 3 %Trapezoidal Load
M = zeros(1,length(x));
Ry = load(2)*load(5) + (load(3)-load(2))*(load(5)/2);
Ma = load(2)*load(5)*(2*load(4)+load(5))/2 + (load(3)-
load(2))*load(5)*(3*load(4)+2*load(5))/6 ;
m = (load(3)-load(2))/load(5);
n = load(2) - (load(3)-load(2))*load(4)/load(5);
M(x<=load(4)) = Ma-Ry*x(x<=load(4));
M(x< load(4)+load(5) - x > load(4)) = (m/6).*x(x<
load(4)+load(5) - x > load(4)).^3 +...
(load(2)-load(4)*m/3+n).*x(x< load(4)+load(5) - x >
load(4)).^2+...
((load(4)^2)*m/6-Ry-load(2)*load(4)-2*load(4)*n).*x(x<
load(4)+load(5) - x > load(4)) +...
Ma+(load(2)*load(4)^2)/2+(load(4)^2)*n;
M(x>= load(4)+load(5)) = 0;
end
if abs(max(M)) > Mmax
Mmax = abs(max(M));
end
for i = 1:length(M)
M(i) = interpolePltBM(M(i));
end
end
end

function V = shearForce(load,x)
%load = [type,magnitude,positions]
V = zeros(1,length(x));
if size(data.load,1) == 1 %it means if there is one load on
a Beam, its mag will becomes Vmax
Vmax = 0;

38
end
rB = get(RbS,'value');
switch rB
case 1 %Case the loads are placed on a Simple Support
switch load(1)
case 1 % Point Load
if ~isempty(V(x==load(3)))
V(x==load(3)) = [load(2)*(len-load(3))/len -
load(2)*load(3)/len];
end
V(x<load(3)) = load(2)*(len-load(3))/len;
V(x>load(3)) = -load(2)*load(3)/len;
if abs(max(V)) > Vmax
Vmax = abs(max(V));
end
for i = 1:length(V)
V(i) = interpolePltSF(V(i));
end
if len - str2double(get(etxta,'string')) <= 0.5
V(end) = interpolePltSF(V(end)) + 0.1;
V(end-1)= interpolePltSF(V(end-1)) + 0.1;
end
if len - str2double(get(etxta,'string')) <= 0.2
V(end) = interpolePltSF(interpolePltSF(V(end)));
V(end-1)= interpolePltSF(interpolePltSF(V(end-1)));
end
case 2 % Uniform Load
Rb = (load(2)*load(4)*(3*load(3)+load(4))
+load(2)*load(4)*(3*load(3)+2*load(4)))/(6*len);
Ra = (load(2)+load(2))*load(4)/2 - Rb;
m = (load(2)-load(2))/load(4);
n = load(2)-(load(2)-load(2))*load(3)/load(4);
r = n/6 + load(2)/3;
V(x<=load(3)) = Ra; %zone 1
V(x<load(3)+load(4) - x<load(3)) =
(-m/2)*x(x<load(3)+load(4) - x<load(3)).^2+...
((load(3)*m/3-r)*2)*x(x<load(3)+load(4) - x<load(3))
+Ra+2*load(3)*r-m*load(3)^2/6; %zone 2
V(x>=load(3)+load(4)) = -Rb; %zone 3
if abs(max(V)) > Vmax

39
Vmax = abs(max(V));
end
for i = 1:length(V)
V(i) = interpolePltSF(V(i));
end

case 3 % Trapezoidal Load


Rb = (load(2)*load(5)*(3*load(4)+load(5))
+load(3)*load(5)*(3*load(4)+2*load(5)))/(6*len);
Ra = (load(3)+load(2))*load(5)/2 - Rb;
m = (load(3)-load(2))/load(5);
n = load(2)-(load(3)-load(2))*load(4)/load(5);
r = n/6 + load(2)/3;
V(x<=load(4)) = Ra; %zone 1
V(x<load(4)+load(5) - x<load(4)) =
(-m/2)*x(x<load(4)+load(5) - x<load(4)).^2+...
((load(4)*m/3-r)*2)*x(x<load(4)+load(5) - x<load(4))
+Ra+2*load(4)*r-m*load(4)^2/6; %zone 2
V(x>=load(4)+load(5)) = -Rb; %zone 3

if abs(max(V)) > Vmax


Vmax = abs(max(V));
end
for i = 1:length(V)
V(i) = interpolePltSF(V(i));
end
end
coord = [x(1),V(1);x(1),0;x(end),V(end);x(end),0];
con = [1,2;3,4];
patch('vertices',coord,'faces',con,'edgecolor','r','tag','shear')
case 0 %Case the loads are placed on a Cantilevered Support

end

end

40
end

41

You might also like