MATLAB SCRIPT FILES
M-files for Plotting Shear Force and Bending Moment Diagrams
%----------------------------------- s.m -----------------------------
%--Copy this into a separate file and name it as s.m-----
function v =s(x,a,n)
%------ Definition of singularity function -----------
%This function will return the value of the singularity function <x-a>^n.
if x<a
v = 0;
else
v = (x-a)^n;
end
%--------------------------------------------------------------------
%----------------------------- V.m -----------------------------------
%--Copy this into a separate file and name it as V.m ----
function val = V(x)
%------ Expression for the shear force ---------------
%This function will return the value of the shear force V(x).
P=500;
b=0.4;
l=1.0;
val = P*(1-b/l)*s(x,0,0)-P*s(x,b,0)+(P*b/l)*s(x,l,0);
%--------------------------------------------------------------------
%----------------------------- M.m -----------------------------------
%--Copy this into a separate file and name it as M.m ----
function val = M(x)
%------ Expression for the bending moment ------------
%This function will return the value of the bending moment M(x).
P=500;
b=0.4;
l=1.0;
val = P*(1-b/l)*s(x,0,1)-P*s(x,b,1)+(P*b/l)*s(x,l,1);
%--------------------------------------------------------------------
To plot the shear force diagrma using Matlab, use the following command:
>> fplot('V',[0 1.0])
To plot the bending moment diagram using Matlab, use the following command:
>> fplot('M',[0 1.0])
To scale the axis:
axis([xmin xmax ymin ymax])
e.g., axis([0 1 -500 500])
|