Matlab program
prob6_3 below shows how to generate
shear force and
bending moment diagrams for a beam.Problem 6.3 of Hibbeler’s textbook,
‘Mechanics of Materials’, 8th. edition,
using US system of customary units.
%
prob6_3.m
% Daniel
A. Landeros Rojas / Ricardo E. Avila Montoya % Mechanics of Materials / August 30, 2013
% ricardo_avila@hotmail.com
% Chihuahua, Mexico
clc
cleardisp(' ')
disp('Problem 6.3, Hibbeler, 8th. edition')
% Data
input section
% The
units of the problem are US customary, not SI % A crane lifts a 1200 Lb load applied at its end, with the
% power of a hydraulic cylinder. Length of beam is 8 feet.
delta_x =
.5; %
Increment for discretization of x axis.
x = (0: delta_x:
96)'; % Generate column array for
x-axis.
FAy =
-2000; % Vertical force at point A
FBy = 3200; % Vertical force at point B FCy = -1200; % Applied load at point C
N = size(x, 1); % Size of
the x-axis discretization
V = zeros(N, 1); % Shear force function of x.
M = V; % Bending moment function of x.
% Data
processing section
for index = 1:
N; % For every discrete point along
x.
% First portion of the beam, 0
< x < 36 (inch)
V(index) = FAy;M(index) = FAy*x(index);
% Second portion of the beam, 36
< x < 96 (inch)
if(x(index)>=36)V(index) = V(index) + FBy;
M(index) = M(index) + FBy*(x(index)-36);
end
end
V(N) = V(N) +
FCy; % Shear force for last point of
diagram
% Data
post-processing section
% Shear
force diagram
figure(1)plot(x,V, 'b', 'linewidth', 2.5)
grid
xlabel('x, inch')
ylabel('Shear force, Lb')
title('Shear force diagram')
axis tight
% Bending
moment diagram
figure(2)plot(x,M, 'r', 'linewidth', 2.5)
grid
xlabel('x, inch')
ylabel('Bending moment, Lb-in')
title('Bending Moment diagram')
axis tight
disp(' ')
disp('***
Successful execution of program ***')% end of Matlab program
figure(1)
figure(2)
________________________________________________________________________
How could you vectorize this?
ReplyDelete