% M File to calculate the deflection of a beam
%
% This file calls the cantiliverBeam function (contained in cantiliverBeam.m file)

% Date:
% Programmer : T. Trani

% Inputs to function cantiliverBeam

% W = load (lb)
% E = Modulus of elasticity (lb/sq-in)
% I = Moment of inertia (in-in-in-in)
% x = distance from datum point (in)
% l = beam length (in)
% distNeutralAxis = distance from edge of beam to neutral axis (in)

% Outputs of function cantiliverBeam

% y = deflection (in)
% s = stress at the cross-section being evaluated (lb/in-in)
% Z = section modulus of the cross section of the beam
% Z is calculated as I / distance from neutral axis to edge of the beam


% Enter the properties of a beam to be calculated

W = 4000;
E = 11e6;
I = 258;
x = 0:1:300;
beamLength = 300;
distNeutralAxis = 12;

% Call the cantilever beam function

[y,s] = cantiliverBeam(W,E,I,x,beamLength,distNeutralAxis);

subplot(2,1,1)
plot(x,y,'o--','LineWidth',1,...
                'MarkerEdgeColor','r',...
                'MarkerFaceColor','g',...
                'MarkerSize',2)
grid
xlabel('Distance from Support (in)')
ylabel('Deflection (in)')

subplot(2,1,2)
plot(x,s,'o--','LineWidth',1,...
                'MarkerEdgeColor','b',...
                'MarkerFaceColor','k',...
                'MarkerSize',2)
grid
xlabel('Distance from Support (in)')
ylabel('Stress (lb/in-in)')


