This document describes a beam deflection analysis program developed by Alex Larcheveque and Matthew Cheng. The program calculates beam deflections and rotation angles for simply supported and cantilever beams. It allows the user to input beam properties and load values, then graphs the deflection vs. distance and rotation angle vs. distance. The program was developed by first writing pseudocode, then creating the calculation function and GUI. It was thoroughly tested against provided test cases and graphs to ensure accuracy.
This presentation begins with explaining the basic algorithms of machine learning and using the same concepts, discusses in detail 2 supervised learning/deep learning algorithms - Artificial neural nets and Convolutional Neural Nets. The relationship between Artificial neural nets and basic machine learning algorithms such as logistic regression and soft max is also explored. For hands on the implementation of ANN's and CNN's on MNIST dataset is also explained.
This presentation begins with explaining the basic algorithms of machine learning and using the same concepts, discusses in detail 2 supervised learning/deep learning algorithms - Artificial neural nets and Convolutional Neural Nets. The relationship between Artificial neural nets and basic machine learning algorithms such as logistic regression and soft max is also explored. For hands on the implementation of ANN's and CNN's on MNIST dataset is also explained.
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfmeerobertsonheyde608
Consider a 4-Link robot manipulator shown below. Use the forward kinematic D-H table and
write an m file that plots the manipulator. The instructions are given in the module 6. Submit
your solutions by the due date, in a single MATLAB m file.
Solution
Please give the kinetic D-H table else it would be difficult to code as we need to know the
rotation spin axis and other momentum of manipulator
Stating a general example code for manipulator with data
function X = fwd_kin(q,x)
% given a position in the configuration space, calculate the position of
% the end effector in the workspace for a two-link manipulator.
% q: vector of joint positions
% x: design vector (link lengths)
% X: end effector position in cartesian coordinates
% configuration space coordinates:
q1 = q(1); % theta 1
q2 = q(2); % theta 2
% manipulator parameters:
l1 = x(1); % link 1 length
l2 = x(2); % link 2 length
% calculate end effector position:
X = [l1*cos(q1) + l2*cos(q1+q2)
l1*sin(q1) + l2*sin(q1+q2)];
% SimulateTwolink.m uses inverse dynamics to simulate the torque
% trajectories required for a two-link planar robotic manipulator to follow
% a prescribed trajectory. It also computes total energy consumption. This
% code is provided as supplementary material for the paper:
%
% \'Engineering System Co-Design with Limited Plant Redesign\'
% Presented at the 8th AIAA Multidisciplinary Design Optimization
% Specialist Conference, April 2012.
%
% The paper is available from:
%
% http://systemdesign.illinois.edu/publications/All12a.pdf
%
% Here both the physical system design and control system design are
% considered simultaneously. Manipulator link length and trajectory
% specification can be specified, and torque trajectory and energy
% consumption are computed based on this input. It was found that maximum
% torque and total energy consumption calculated using inverse dynamics
% agreed closely with results calculated using feedback linearization, so
% to simplify optimization problem solution an inverse dynamics approach
% was used, which reduces the control design vector to just the trajectory
% design.
%
% In the conference paper several cases are considered, each with its own
% manipulator task, manipulator design, and trajectory design. The
% specifications for each of these five cases are provided here, and can be
% explored by changing the case number variable (cn).
%
% This code was incorporated into a larger optimization project. The code
% presented here includes only the analysis portion of the code, no
% optimization.
%
% A video illustrating the motion of each of these five cases is available
% on YouTube:
%
% http://www.youtube.com/watch?v=OR7Y9-n5SjA
%
% Author: James T. Allison, Assistant Professor, University of Illinois at
% Urbana-Champaign
% Date: 4/10/12
clear;clc
% simulation parameters:
p.dt = 0.0005; % simulation step size
tf = 2; p.tf = tf; % final time
p.ploton = 0; % turn off additional plotting capabilities
p.ploton2 = 0;
p.Tallow = 210; % maximum .
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxvrickens
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition pg. 25
An Introduction to
Computer Science with Java, Python and C++
Community College of Philadelphia edition
Copyright 2017 by C.W. Herbert, all rights reserved.
Last edited October 8, 28, 2019 by C. W. Herbert
This document is a draft of a chapter from An Introduction to Computer Science with Java, Python and C++, written by Charles Herbert. It is available free of charge for students in Computer Science courses at Community College of Philadelphia during the Fall 2019 semester. It may not be reproduced or distributed for any other purposes without proper prior permission.
Please report any typos, other errors, or suggestions for improving the text to [email protected]
Chapter 5 – Python Functions and Modular Programming
Contents
Lesson 5.1User Created Functions in Python2
Python Function Parameters2
Value returning functions3
Example – Methods and Parameter Passing5
9
Lesson 5.2Top-Down Design and Modular Development10
Chapter Exercises13
User Created Functions in Python
So far we have only created software with one continuous Python script. We have used functions from other python modules, such as the square root method from the math class math.sqrt(n). Now we will begin to create our own functions of our own.
A Python function is a block of code that can be used to perform a specific task within a larger computer program. It can be called as needed from other Python software. Most programming languages have similar features, such as methods in Java or subroutines in system software.
The code for user-defined functions in Python is contained in a function definition. A Python function definition is a software unit with a header and a block of Python statements. The header starts with the keyword def followed by the name of the function, then a set parenthesis with any parameters for the function. A colon is used after the parentheses to indicate a block of code follows, just as with the if and while statements. The block of code to be included within the function is indented.
Here is an example of a Python function:
# firstFunction.py
# first demonstration of the use of a function for CSCI 111
# last edited 10/08/2o19 by C. Herbert
function
definition
def myFunction():
print ( "This line being printed by the function MyFunction.\n")
# end myFunction()
### main program ###
function used by the main part of the script
print("Beginning\n")
myFunction()
print("End\n")
# end main program
Functions can used for code that will be repeated within a program, or for modular development, in which long programs are broken into parts and the parts are developed independently. The parts can be developed as Python functions, then integrated to work together by being called from other software.
Python Function Parameters
Data can be passed to a Python function as a parameter of the function. Function parameters are variables listed in parentheses foll ...
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisDr.Costas Sachpazis
This simple Python software is designed to assist Civil and Geotechnical Engineers in performing site-specific seismic hazard assessments. The program calculates the seismic response spectrum based on user-provided geotechnical and seismic parameters, generating a comprehensive technical report that includes the response spectrum data and figures. The analysis adheres to Eurocode 8 and the Greek Annex, ensuring compliance with international standards for earthquake-resistant design.
Lab Practices and Works Documentation / Report on Computer GraphicsRup Chowdhury
This is a report that I have prepared during my Computer Graphics Lab course. This contains the theoretical information that we learned in our introduction class. It also contains information on different computer graphics tools and software. It contains codes to create different and also the procedure.
1. Information on GLUT
2. Flag drawing with GLUT
3. DDA Algorithm
4. Midpoint Line Drawing Algorithm
5. Tansformation
Preparing
Benchmark
How to Load Files on NativeActivity
How to Make Hand Detector
Calculate Histgram of Skin Color
Detect Skin Area from CapImage
Calculate the Largest Skin Area
Matching Histgrams
MATLAB is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfmeerobertsonheyde608
Consider a 4-Link robot manipulator shown below. Use the forward kinematic D-H table and
write an m file that plots the manipulator. The instructions are given in the module 6. Submit
your solutions by the due date, in a single MATLAB m file.
Solution
Please give the kinetic D-H table else it would be difficult to code as we need to know the
rotation spin axis and other momentum of manipulator
Stating a general example code for manipulator with data
function X = fwd_kin(q,x)
% given a position in the configuration space, calculate the position of
% the end effector in the workspace for a two-link manipulator.
% q: vector of joint positions
% x: design vector (link lengths)
% X: end effector position in cartesian coordinates
% configuration space coordinates:
q1 = q(1); % theta 1
q2 = q(2); % theta 2
% manipulator parameters:
l1 = x(1); % link 1 length
l2 = x(2); % link 2 length
% calculate end effector position:
X = [l1*cos(q1) + l2*cos(q1+q2)
l1*sin(q1) + l2*sin(q1+q2)];
% SimulateTwolink.m uses inverse dynamics to simulate the torque
% trajectories required for a two-link planar robotic manipulator to follow
% a prescribed trajectory. It also computes total energy consumption. This
% code is provided as supplementary material for the paper:
%
% \'Engineering System Co-Design with Limited Plant Redesign\'
% Presented at the 8th AIAA Multidisciplinary Design Optimization
% Specialist Conference, April 2012.
%
% The paper is available from:
%
% http://systemdesign.illinois.edu/publications/All12a.pdf
%
% Here both the physical system design and control system design are
% considered simultaneously. Manipulator link length and trajectory
% specification can be specified, and torque trajectory and energy
% consumption are computed based on this input. It was found that maximum
% torque and total energy consumption calculated using inverse dynamics
% agreed closely with results calculated using feedback linearization, so
% to simplify optimization problem solution an inverse dynamics approach
% was used, which reduces the control design vector to just the trajectory
% design.
%
% In the conference paper several cases are considered, each with its own
% manipulator task, manipulator design, and trajectory design. The
% specifications for each of these five cases are provided here, and can be
% explored by changing the case number variable (cn).
%
% This code was incorporated into a larger optimization project. The code
% presented here includes only the analysis portion of the code, no
% optimization.
%
% A video illustrating the motion of each of these five cases is available
% on YouTube:
%
% http://www.youtube.com/watch?v=OR7Y9-n5SjA
%
% Author: James T. Allison, Assistant Professor, University of Illinois at
% Urbana-Champaign
% Date: 4/10/12
clear;clc
% simulation parameters:
p.dt = 0.0005; % simulation step size
tf = 2; p.tf = tf; % final time
p.ploton = 0; % turn off additional plotting capabilities
p.ploton2 = 0;
p.Tallow = 210; % maximum .
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxvrickens
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition pg. 25
An Introduction to
Computer Science with Java, Python and C++
Community College of Philadelphia edition
Copyright 2017 by C.W. Herbert, all rights reserved.
Last edited October 8, 28, 2019 by C. W. Herbert
This document is a draft of a chapter from An Introduction to Computer Science with Java, Python and C++, written by Charles Herbert. It is available free of charge for students in Computer Science courses at Community College of Philadelphia during the Fall 2019 semester. It may not be reproduced or distributed for any other purposes without proper prior permission.
Please report any typos, other errors, or suggestions for improving the text to [email protected]
Chapter 5 – Python Functions and Modular Programming
Contents
Lesson 5.1User Created Functions in Python2
Python Function Parameters2
Value returning functions3
Example – Methods and Parameter Passing5
9
Lesson 5.2Top-Down Design and Modular Development10
Chapter Exercises13
User Created Functions in Python
So far we have only created software with one continuous Python script. We have used functions from other python modules, such as the square root method from the math class math.sqrt(n). Now we will begin to create our own functions of our own.
A Python function is a block of code that can be used to perform a specific task within a larger computer program. It can be called as needed from other Python software. Most programming languages have similar features, such as methods in Java or subroutines in system software.
The code for user-defined functions in Python is contained in a function definition. A Python function definition is a software unit with a header and a block of Python statements. The header starts with the keyword def followed by the name of the function, then a set parenthesis with any parameters for the function. A colon is used after the parentheses to indicate a block of code follows, just as with the if and while statements. The block of code to be included within the function is indented.
Here is an example of a Python function:
# firstFunction.py
# first demonstration of the use of a function for CSCI 111
# last edited 10/08/2o19 by C. Herbert
function
definition
def myFunction():
print ( "This line being printed by the function MyFunction.\n")
# end myFunction()
### main program ###
function used by the main part of the script
print("Beginning\n")
myFunction()
print("End\n")
# end main program
Functions can used for code that will be repeated within a program, or for modular development, in which long programs are broken into parts and the parts are developed independently. The parts can be developed as Python functions, then integrated to work together by being called from other software.
Python Function Parameters
Data can be passed to a Python function as a parameter of the function. Function parameters are variables listed in parentheses foll ...
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisDr.Costas Sachpazis
This simple Python software is designed to assist Civil and Geotechnical Engineers in performing site-specific seismic hazard assessments. The program calculates the seismic response spectrum based on user-provided geotechnical and seismic parameters, generating a comprehensive technical report that includes the response spectrum data and figures. The analysis adheres to Eurocode 8 and the Greek Annex, ensuring compliance with international standards for earthquake-resistant design.
Lab Practices and Works Documentation / Report on Computer GraphicsRup Chowdhury
This is a report that I have prepared during my Computer Graphics Lab course. This contains the theoretical information that we learned in our introduction class. It also contains information on different computer graphics tools and software. It contains codes to create different and also the procedure.
1. Information on GLUT
2. Flag drawing with GLUT
3. DDA Algorithm
4. Midpoint Line Drawing Algorithm
5. Tansformation
Preparing
Benchmark
How to Load Files on NativeActivity
How to Make Hand Detector
Calculate Histgram of Skin Color
Detect Skin Area from CapImage
Calculate the Largest Skin Area
Matching Histgrams
MATLAB is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages
1. DESIGN PROJECT – ME018
PROJECT BY: ALEX LARCHEVEQUE AND MATTHEW CHENG
Functionality:
Our program calculates beam deflections and the angle of rotation of the axis of the beam
for two types of beams: the simply-supported and the cantilever beam. We allow the user to
input important information about the beam in two metric systems, the US customary units
and SI units. These user input values that include 1) the beam’s length, 2) the elastic modulus
of the material, 3) the moment of inertia of the beam’s cross section, 4) the value of load on
the beam, 5) the location of the load. After the user inputs needed information, our program
graphs beam deflection vs. distance and the rotation angle vs. distance. Our program also
finds the max deflection value and the location at where the max deflection occurs. After the
user has retrieved their information, we included a simple “clear” button that allows the user
to easily reset their program.
Development:
We developed this program by writing out our pseudocode first, and then started the back-
end development. After the back-end development was completed (1 function m-file), we
completed the GUI (front-end) portion of our program. In between each development
stage, we constantly ran our program to see if we would output the correct values and
graphs.
Testing Procedures:
Once we completed the back-end code, we tested the values that were posted in the design
handout, and checked them with Professor Sawyer’s graphs to see if our function was
correct. At first, our simply-supported beam code was not correct. We checked our code
over and over again, and found that we forgot to multiply a simple L in one of our formulas.
We fixed it, and got our program to be correct.
We then moved on to the front-end development. During the front-end development, we
would constantly update the GUI, and test our code with the values in the design handout.
We constantly tested our code to catch any bugs that would come up. We would see if our
outputted graphs matched Professor Sawyer’s graphs, and would also see if we retrieved the
same max deflection point values.
8. 8
Calculation and Plotting Function:
% Larcheveque, Alexander
% Cheng, Matt
% Application for Deflection Analysis Beam
% 11/20/2015
function DesignProject (L, E, I, P, a, beamtype)
%Calculates and plots the bean deflections based on the displacement in
the
%y-dorection of point x on the axis of the beam
%PUTWITHGUI : Convert units if not U.S. system
% %Convert m to inches
% if userButton1 == m
% L = (39.3701) .* (L);
% end
%
% %Convert GPa to psi
% if userButton2 == GPa
% E = (145037.73773) .* (E);
% end
%
% %Convert mm.^4 to in.^4
% if userButton3 == mm.^4
% I = (2.40250961.*10.^-6) .* I;
% end
%
% %Convert N to lb
% if userButton4 == N
% P = (0.2248089) .* (P);
% end
%
% %Convert kN to lb
% if userButton4 == kN
% P = (224.80894) .* (P);
% end
%
% %Convert m to inches
% if userButton5 == m
% a = (39.3701) .* (L);
% end
%Check from mistakes that user inserts
if a > L
disp('Your force cannot exceed the beam');
return;
end
%Continue checking for user mistakes (if user did not enter valid beam
%type)
s1 = 'cantilever';
9. 9
s2 = 'simply-supported';
s3 = beamtype;
tf = strcmp(s1,s3);
tf2 = strcmp(s2,s3);
if (tf == 0) && (tf2 == 0)
disp('You did not enter a valid beam type');
return;
end
%Use switch to choose which calculations to use
switch beamtype
case 'simply-supported'
%Calculation for simply supported beam
%Calculate b
b = L - a;
x = linspace(0,L,500);
v = zeros(1, length(x));
%Initialize v_ans & der_v_ans array, also initialize angle, deflection
of
%midpoint, distance from max. deflection, and max deflect
v = zeros(1, length(x));
der_v = zeros(1, length(x));
angle_A = zeros(1, length(x));
angle_B = zeros(1, length(x));
def_midpointC = zeros(1, length(x));
dist_from_max_deflect = zeros(1, length(x));
maxdeflect = zeros(1, length(x));
for ii = 1:length(x)
if (x(ii) <= a) && (x(ii) >= 0)
v(ii) = -((P.*b.*x(ii)) .* (L.^2 - b.^2 - x(ii).^2)) ./
(6.*L.*E.*I);
der_v(ii) = (-((P.*b).*(L.^2 - b.^2 - 3.*(x(ii).^2))) ./
(6.*L.*E.*I));
end
if (x(ii) <= L) && (x(ii) > a)
v(ii) = -(((P.*b.*x(ii)) .* (L.^2-b.^2-x(ii).^2)) ./
(6.*L.*E.*I)) - P.*(x(ii) - a).^3 ./ (6.*E.*I);
der_v(ii) = (-(P.*b).*(L.^2 - b.^2 - 3.*(x(ii).^2)) ./
(6.*L.*E.*I)) - (P.*((x(ii) - a).^2) ./ (2.*E.*I));
10. 10
end
angle_A(ii) = (P.*a.*b).*(L + b) ./ (6.*L.*E.*I);
angle_B(ii) = (P.*a.*b).*(L + a) ./ (6.*L.*E.*I);
if (a >= b)
def_midpointC(ii) = P.*b.*(3.*L.^2 - 4.*b.^2) ./ (48.*E.*I);
dist_from_max_deflect(ii) = sqrt((L.^2 - b.^2) ./ 3);
maxdeflect(ii) = (P.*b.*(L.^2 - b.^2).^(3/2)) ./
(9.*sqrt(3).*L.*E.*I);
else
def_midpointC(ii) = P.*a.*(3.*L.^2 - 4.*a.^2) ./ (48.*E.*I);
end
end
x = linspace(0,L,500);
subplot(2,1,1, 'FontSize', 12);
plot(x,v,'LineWidth', 3);
xlim([0 L]);
title({'Simply-Supported Beam','Deflection vs. Distance'});
ylabel('Y-Direction Deflection (in.)');
%Find minimum point
indexmin = find(min(v) == v);
xmin = x(indexmin);
ymin = v(indexmin);
% strmin = ['Max Deflection = ',num2str(ymin)];
strmin = ['Max deflection =',num2str(ymin), 'in. @ x =
',num2str(xmin)];
text(xmin-1, ymin+0.0005, strmin);
subplot(2,1,2, 'FontSize', 12);
plot(x, der_v, 'LineWidth', 3);
xlim([0 L]);
title('Rotation Angle vs. Distance');
xlabel('Distance From Support');
ylabel('Rotation Angle');
case 'cantilever'
%Calculate b
b = L - a;
11. 11
x = linspace(0,L,500);
v = zeros(1, length(x));
%Initialize v & der_v_ans array
v = zeros(1, length(x));
der_v = zeros(1, length(x));
%Compute calculations for each set of specific values
for ii = 1:length(x)
if (x(ii) <= a) && (x(ii) >= 0)
v(ii) = -((P.*x(ii).^2) .* (3.*a - x(ii))) ./ (6.*E.*I);
der_v(ii) = -((P.*x(ii)).*(2.*a - x(ii))) ./ (2.*E.*I);
end
if (x(ii) <= L) && (x(ii) > a)
v(ii) = -((P.*a.^2) .* (3.*x(ii) - a)) ./ (6.*E.*I);
der_v(ii) = -(P.*a.^2) ./ (2.*E.*I);
end
if x(ii) == a
v(ii) = -(P.*a.^3) ./ (3.*E.*I);
der_v(ii) = -(P .* a.^2) ./ (2.*E.*I);
deflect = ((P.*a.^2).*(3.*L-a)) ./ (6.*E.*I);
anglerot = (P.*a.^2) ./ (2.*E.*I);
end
end
subplot(2,1,1, 'FontSize', 12);
plot(x,v,'LineWidth', 3);
title({'Cantilever Beam','Deflection vs. Distance'});
ylabel('Y-Direction Deflection (in.)');
%Find minimum point
indexmin = find(min(v) == v);
xmin = x(indexmin);
ymin = v(indexmin);
% strmin = ['Max Deflection = ',num2str(ymin)];
strmin = ['Max deflection =',num2str(ymin), 'in. @ x =
',num2str(xmin)];
text(xmin-1, ymin+0.0005, strmin);
subplot(2,1,2, 'FontSize', 12);
plot(x,der_v, 'LineWidth', 3);
title('Rotation Angle vs. Distance');
xlabel('Distance From Support');
13. 13
Main GUI Function:
function varargout = BeamDeflectionAnalysis(varargin)
% BEAMDEFLECTIONANALYSIS MATLAB code for BeamDeflectionAnalysis.fig
% BEAMDEFLECTIONANALYSIS, by itself, creates a new
BEAMDEFLECTIONANALYSIS or raises the existing
% singleton*.
%
% H = BEAMDEFLECTIONANALYSIS returns the handle to a new
BEAMDEFLECTIONANALYSIS or the handle to
% the existing singleton*.
%
% BEAMDEFLECTIONANALYSIS('CALLBACK',hObject,eventData,handles,...)
calls the local
% function named CALLBACK in BEAMDEFLECTIONANALYSIS.M with the
given input arguments.
%
% BEAMDEFLECTIONANALYSIS('Property','Value',...) creates a new
BEAMDEFLECTIONANALYSIS or raises the
% existing singleton*. Starting from the left, property value
pairs are
% applied to the GUI before BeamDeflectionAnalysis_OpeningFcn gets
called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to
BeamDeflectionAnalysis_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only
one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help
BeamDeflectionAnalysis
% Last Modified by GUIDE v2.5 23-Nov-2015 10:23:06
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn',
@BeamDeflectionAnalysis_OpeningFcn, ...
'gui_OutputFcn', @BeamDeflectionAnalysis_OutputFcn,
...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
14. 14
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before BeamDeflectionAnalysis is made visible.
function BeamDeflectionAnalysis_OpeningFcn(hObject, eventdata, handles,
varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to BeamDeflectionAnalysis (see
VARARGIN)
% Choose default command line output for BeamDeflectionAnalysis
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes BeamDeflectionAnalysis wait for user response (see
UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = BeamDeflectionAnalysis_OutputFcn(hObject,
eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in run.
function run_Callback(hObject, eventdata, handles)
% hObject handle to run (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
L = str2num(get(handles.l1,'String'));
E = str2num(get(handles.e1,'String'));
I = str2num(get(handles.i1,'String'));
P = str2num(get(handles.p1,'String'));
A = str2num(get(handles.a1,'String'));
15. 15
B = get(handles.beamtype,'SelectedObject');
beamtype = get(B,'String');
%Switch to choose which calculations to use
switch beamtype
case 'Simply-Supported'
%Calculate b
b = L - A;
x = linspace(0,L,500);
v = zeros(1, length(x));
%Initialize v_ans & der_v_ans array, also initialize angle, deflection
of
%midpoint, distance from max. deflection, and max deflect
v = zeros(1, length(x));
der_v = zeros(1, length(x));
angle_A = zeros(1, length(x));
angle_B = zeros(1, length(x));
def_midpointC = zeros(1, length(x));
dist_from_max_deflect = zeros(1, length(x));
maxdeflect = zeros(1, length(x));
for ii = 1:length(x)
if (x(ii) <= A) && (x(ii) >= 0)
v(ii) = -((P.*b.*x(ii)) .* (L.^2 - b.^2 - x(ii).^2)) ./
(6.*L.*E.*I);
der_v(ii) = (-((P.*b).*(L.^2 - b.^2 - 3.*(x(ii).^2))) ./
(6.*L.*E.*I));
end
if (x(ii) <= L) && (x(ii) > A)
v(ii) = -(((P.*b.*x(ii)) .* (L.^2-b.^2-x(ii).^2)) ./
(6.*L.*E.*I)) - P.*(x(ii) - A).^3 ./ (6.*E.*I);
der_v(ii) = (-(P.*b).*(L.^2 - b.^2 - 3.*(x(ii).^2)) ./
(6.*L.*E.*I)) - (P.*((x(ii) - A).^2) ./ (2.*E.*I));
end
angle_A(ii) = (P.*A.*b).*(L + b) ./ (6.*L.*E.*I);
angle_B(ii) = (P.*A.*b).*(L + A) ./ (6.*L.*E.*I);
if (A >= b)
def_midpointC(ii) = P.*b.*(3.*L.^2 - 4.*b.^2) ./ (48.*E.*I);
dist_from_max_deflect(ii) = sqrt((L.^2 - b.^2) ./ 3);
maxdeflect(ii) = (P.*b.*(L.^2 - b.^2).^(3/2)) ./
(9.*sqrt(3).*L.*E.*I);
else
def_midpointC(ii) = P.*A.*(3.*L.^2 - 4.*A.^2) ./ (48.*E.*I);
end
16. 16
end
x = linspace(0,L,500);
axes(handles.axes1);
plot(x,v,'LineWidth', 3);
xlim([0 L]);
ylabel('Y-Direction Deflection (in.)');
%Find minimum point
indexmin = find(min(v) == v);
xmin = x(indexmin);
xx = num2str(xmin);
set(handles.xmax,'String',xx);
ymin = v(indexmin);
yy = num2str(ymin);
set(handles.ymax,'String',yy);
axes(handles.axes2);
plot(x, der_v, 'LineWidth', 3);
xlim([0 L]);
xlabel('Distance From Support');
ylabel('Rotation Angle');
case 'Cantilever'
%Calculate b
b = L - A;
x = linspace(0,L,500);
v = zeros(1, length(x));
%Initialize v & der_v_ans array
v = zeros(1, length(x));
der_v = zeros(1, length(x));
%Compute calculations for each set of specific values
for ii = 1:length(x)
if (x(ii) <= A) && (x(ii) >= 0)
v(ii) = -((P.*x(ii).^2) .* (3.*A - x(ii))) ./ (6.*E.*I);
der_v(ii) = -((P.*x(ii)).*(2.*A - x(ii))) ./ (2.*E.*I);
end
if (x(ii) <= L) && (x(ii) > A)
v(ii) = -((P.*A.^2) .* (3.*x(ii) - A)) ./ (6.*E.*I);
der_v(ii) = -(P.*A.^2) ./ (2.*E.*I);
end
17. 17
if x(ii) == A
v(ii) = -(P.*A.^3) ./ (3.*E.*I);
der_v(ii) = -(P .* A.^2) ./ (2.*E.*I);
deflect = ((P.*A.^2).*(3.*L-A)) ./ (6.*E.*I);
anglerot = (P.*A.^2) ./ (2.*E.*I);
end
end
axes(handles.axes1);
plot(x,v,'LineWidth', 3);
ylabel('Y-Direction Deflection (in.)');
%Find minimum point
indexmin = find(min(v) == v);
xmin = x(indexmin);
xx = num2str(xmin);
set(handles.xmax,'String',xx);
ymin = v(indexmin);
yy = num2str(ymin);
set(handles.ymax,'String',yy);
axes(handles.axes2);
plot(x,der_v, 'LineWidth', 3);
xlabel('Distance From Support');
ylabel('Rotation Angle');
end
% --- Executes on button press in run2.
function run2_Callback(hObject, eventdata, handles)
% hObject handle to run2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
L1 = str2num(get(handles.l2,'String'));
E1 = str2num(get(handles.e2,'String'));
I1 = str2num(get(handles.i2,'String'));
P1 = str2num(get(handles.p2,'String'));
A1 = str2num(get(handles.a2,'String'));
B1 = get(handles.beamtype,'SelectedObject');
beamtype1 = get(B1,'String');
%Switch to choose which calculations to use
switch beamtype1
case 'Simply-Supported'
%Calculate b
b = L1 - A1;
18. 18
x = linspace(0,L1,500);
v = zeros(1, length(x));
%Initialize v_ans & der_v_ans array, also initialize angle, deflection
of
%midpoint, distance from max. deflection, and max deflect
v = zeros(1, length(x));
der_v = zeros(1, length(x));
angle_A = zeros(1, length(x));
angle_B = zeros(1, length(x));
def_midpointC = zeros(1, length(x));
dist_from_max_deflect = zeros(1, length(x));
maxdeflect = zeros(1, length(x));
for ii = 1:length(x)
if (x(ii) <= A1) && (x(ii) >= 0)
v(ii) = -((P1.*b.*x(ii)) .* (L1.^2 - b.^2 - x(ii).^2)) ./
(6.*L1.*E1.*I1);
der_v(ii) = (-((P1.*b).*(L1.^2 - b.^2 - 3.*(x(ii).^2))) ./
(6.*L1.*E1.*I1));
end
if (x(ii) <= L1) && (x(ii) > A1)
v(ii) = -(((P1.*b.*x(ii)) .* (L1.^2-b.^2-x(ii).^2)) ./
(6.*L1.*E1.*I1)) - P1.*(x(ii) - A1).^3 ./ (6.*E1.*I1);
der_v(ii) = (-(P1.*b).*(L1.^2 - b.^2 - 3.*(x(ii).^2)) ./
(6.*L1.*E1.*I1)) - (P1.*((x(ii) - A1).^2) ./ (2.*E1.*I1));
end
angle_A(ii) = (P1.*A1.*b).*(L1 + b) ./ (6.*L1.*E1.*I1);
angle_B(ii) = (P1.*A1.*b).*(L1 + A1) ./ (6.*L1.*E1.*I1);
if (A1 >= b)
def_midpointC(ii) = P1.*b.*(3.*L1.^2 - 4.*b.^2) ./
(48.*E1.*I1);
dist_from_max_deflect(ii) = sqrt((L1.^2 - b.^2) ./ 3);
maxdeflect(ii) = (P1.*b.*(L1.^2 - b.^2).^(3/2)) ./
(9.*sqrt(3).*L1.*E1.*I1);
else
def_midpointC(ii) = P1.*A1.*(3.*L1.^2 - 4.*A1.^2) ./
(48.*E1.*I1);
end
end
x = linspace(0,L1,500);
axes(handles.axes1);
plot(x,v,'LineWidth', 3);
xlim([0 L1]);
ylabel('Y-Direction Deflection (in.)');
19. 19
%Find minimum point
indexmin = find(min(v) == v);
xmin = x(indexmin);
xx = num2str(xmin);
set(handles.xmax,'String',xx);
ymin = v(indexmin);
yy = num2str(ymin);
set(handles.ymax,'String',yy);
axes(handles.axes2);
plot(x, der_v, 'LineWidth', 3);
xlim([0 L1]);
xlabel('Distance From Support');
ylabel('Rotation Angle');
case 'Cantilever'
%Calculate b
b = L1 - A1;
x = linspace(0,L1,500);
v = zeros(1, length(x));
%Initialize v & der_v_ans array
v = zeros(1, length(x));
der_v = zeros(1, length(x));
%Compute calculations for each set of specific values
for ii = 1:length(x)
if (x(ii) <= A1) && (x(ii) >= 0)
v(ii) = -((P1.*x(ii).^2) .* (3.*A1 - x(ii))) ./ (6.*E1.*I1);
der_v(ii) = -((P1.*x(ii)).*(2.*A1 - x(ii))) ./ (2.*E1.*I1);
end
if (x(ii) <= L1) && (x(ii) > A1)
v(ii) = -((P1.*A1.^2) .* (3.*x(ii) - A1)) ./ (6.*E1.*I1);
der_v(ii) = -(P1.*A1.^2) ./ (2.*E1.*I1);
end
if x(ii) == A1
v(ii) = -(P1.*A1.^3) ./ (3.*E1.*I1);
der_v(ii) = -(P1 .* A1.^2) ./ (2.*E1.*I1);
deflect = ((P1.*A1.^2).*(3.*L1-A1)) ./ (6.*E1.*I1);
anglerot = (P1.*A1.^2) ./ (2.*E1.*I1);
end
20. 20
end
axes(handles.axes1);
plot(x,v,'LineWidth', 3);
ylabel('Y-Direction Deflection (in.)');
%Find minimum point
indexmin = find(min(v) == v);
xmin = x(indexmin);
xx = num2str(xmin);
set(handles.xmax,'String',xx);
ymin = v(indexmin);
yy = num2str(ymin);
set(handles.ymax,'String',yy);
axes(handles.axes2);
plot(x,der_v, 'LineWidth', 3);
xlabel('Distance From Support');
ylabel('Rotation Angle');
end
% --- Executes on button press in clear.
function clear_Callback(hObject, eventdata, handles)
% hObject handle to clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.l2, 'String', '');
set(handles.e2, 'String', '');
set(handles.i2, 'String', '');
set(handles.p2, 'String', '');
set(handles.a2, 'String', '');
set(handles.l1, 'String', '');
set(handles.e1, 'String', '');
set(handles.i1, 'String', '');
set(handles.p1, 'String', '');
set(handles.a1, 'String', '');
set(handles.xmax, 'String', '');
set(handles.ymax, 'String', '');
% Clear Axes
axes(handles.axes1);
cla
axes(handles.axes2);
cla
function l2_Callback(hObject, eventdata, handles)
% hObject handle to l2 (see GCBO)
21. 21
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of l2 as text
% str2double(get(hObject,'String')) returns contents of l2 as a
double
% --- Executes during object creation, after setting all properties.
function l2_CreateFcn(hObject, eventdata, handles)
% hObject handle to l2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function e2_Callback(hObject, eventdata, handles)
% hObject handle to e2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of e2 as text
% str2double(get(hObject,'String')) returns contents of e2 as a
double
% --- Executes during object creation, after setting all properties.
function e2_CreateFcn(hObject, eventdata, handles)
% hObject handle to e2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function i2_Callback(hObject, eventdata, handles)
22. 22
% hObject handle to i2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of i2 as text
% str2double(get(hObject,'String')) returns contents of i2 as a
double
% --- Executes during object creation, after setting all properties.
function i2_CreateFcn(hObject, eventdata, handles)
% hObject handle to i2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function p2_Callback(hObject, eventdata, handles)
% hObject handle to p2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of p2 as text
% str2double(get(hObject,'String')) returns contents of p2 as a
double
% --- Executes during object creation, after setting all properties.
function p2_CreateFcn(hObject, eventdata, handles)
% hObject handle to p2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
23. 23
function a2_Callback(hObject, eventdata, handles)
% hObject handle to a2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of a2 as text
% str2double(get(hObject,'String')) returns contents of a2 as a
double
% --- Executes during object creation, after setting all properties.
function a2_CreateFcn(hObject, eventdata, handles)
% hObject handle to a2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function l1_Callback(hObject, eventdata, handles)
% hObject handle to l1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of l1 as text
% str2double(get(hObject,'String')) returns contents of l1 as a
double
% --- Executes during object creation, after setting all properties.
function l1_CreateFcn(hObject, eventdata, handles)
% hObject handle to l1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
24. 24
function e1_Callback(hObject, eventdata, handles)
% hObject handle to e1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of e1 as text
% str2double(get(hObject,'String')) returns contents of e1 as a
double
% --- Executes during object creation, after setting all properties.
function e1_CreateFcn(hObject, eventdata, handles)
% hObject handle to e1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function i1_Callback(hObject, eventdata, handles)
% hObject handle to i1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of i1 as text
% str2double(get(hObject,'String')) returns contents of i1 as a
double
% --- Executes during object creation, after setting all properties.
function i1_CreateFcn(hObject, eventdata, handles)
% hObject handle to i1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
25. 25
function p1_Callback(hObject, eventdata, handles)
% hObject handle to p1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of p1 as text
% str2double(get(hObject,'String')) returns contents of p1 as a
double
% --- Executes during object creation, after setting all properties.
function p1_CreateFcn(hObject, eventdata, handles)
% hObject handle to p1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function a1_Callback(hObject, eventdata, handles)
% hObject handle to a1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of a1 as text
% str2double(get(hObject,'String')) returns contents of a1 as a
double
% --- Executes during object creation, after setting all properties.
function a1_CreateFcn(hObject, eventdata, handles)
% hObject handle to a1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end