Cantilever beam deflection using different Cross sectional area (I)moment of inertia

I am unable to get Deflection and Max Deflection for the different Cross sections i inputed. It is solving for just a cross section
%Maximum Deflection and Deflection at any point X on a cantilever beam
disp('inputs your given parameters and input "0"2 for ungiven parameters')
W1=input('W1-Uniform Distributed load, N/mm ?');
W2=input('W2-Triangular Distributed load, N/mm ?');
P1=input('P1-End Point load, N ?');
P2=input('P2-Intermediate Point load, N ?');
L=input('Beam length, mm ?');
b=input('Beam diameter/breadth, m2 ?');
bo =input('Beam breadth inside mm ?');
h=input('Beam depth outside, mm ?');
ho= input('Beam depth inside, mm ?');
k= input ('I flange, mm ?');
a=input('Distance of point load from cantilever (a), mm ?');
Mo=input('MO-End moment, Nmm ?');
disp(' P1 Deflection of a Cantilever beam with End Point load')
disp(' P2 Deflection of a Cantilever beam with Intermediate load')
disp(' UDL Deflection of a Cantilever beam with Uniform Distributed loadings')
disp(' TDL Deflection of a Cantilever beam with Triangular Distributed loadings')
disp(' Mo Deflection of a Cantilever beam with End Moment')
Moment_of_inertias = zeros(5);
Circular = (pi*(b/2)^4/4); %Circular cross section;
Rectangular = (b*h^3/12); %Rectangular cross section;
square = (b^4/12); %square cross section;
I_symmetrical = (k^3 *h)/12 + (b^3 *(h^3-ho^3))/12; % I-cross section symmetrical;
hollow_cylindrical = (pi * (b^4-bo^4)/64); % hollow cylindrical cross section;
Moment_of_inertias(1) = Circular
Moment_of_inertias(2) = Rectangular
Moment_of_inertias(3) = square
Moment_of_inertias(4) = I_symmetrical
Moment_of_inertias(5) = hollow_cylindrical
for m=1:5
I = Moment_of_inertias(m);
end
E=2*10^5; %young modulus N/mm2
x = 0:0.1*L:L;
Deflection = zeros(11);
P1_Max = P1*L^3/ 3*E*I;
P2_Max = P2*a^2*(3*L-a)/ 6*E*I;
UDL_Max = W1*L^4 / 8*E*I;
TDL_Max = W2*L^4/ 30*E*I;
MO_Max = Mo* L^2/2*E*I;
for i = 1:11
P1_Def(i) = -(P1*x(i)^2*(3*L- x(i))/6*E*I);
P2_Def(i) = -(P2*x(i)^2*(3*a-x(i))/6*E*I);%for 0<x<a range
P22_Def(i) = -(P2*a^2*(3*x(i)-a)/6*E*I);%for a<x<L range
UDL_Def(i) = -(W1*x(i)^2*((x(i)^2)+(6*L^2)-(4*L*x(i)))/24*E*I);
TDL_Def(i) = -(W2*x(i)^2*((10*L^3)-(10*L^2*x(i))+(5*L*x(i)^2)-(x(i)^3))/(120*L*E*I));
MO_Def(i) = -(Mo* x(i)^2/2*E*I);
end
Loading = input('Enter 1 for P1 +, 2 for P2 +, 3 for UDL +, 4 for TDL +, 5 for Mo +, = ');
if (Loading == 1);
double_loadings = input('Enter 1 for P1, 2 for P1+P2, 3 for P1+UDL, 4 for P1+TDL, 5 for P1+Mo =');
if(double_loadings == 1);% for a single point Point load at the end of the cantilever beam
Deflection = P1_Def;
Max_Deflection = P1_Max
elseif(double_loadings == 2);% for both end Point load and intermediate load.
Range_across_beam_length = input('Enter 1 for 0<x<a range, Enter 2 for a<x<L range = ');
if (Range_across_beam_length == 1); %for both end Point load and intermediate load 0<x<a range
Deflection = P1_Def + P2_Def
elseif (Range_across_beam_length == 2); %for both end Point load and intermediate load a<x<L range
Deflection = P1_Def + P22_Def;
end
Max_Deflection = P1_Max + P2_Max
elseif (double_loadings == 3);% for both end Point load and UDL load.
Deflection = P1_Def + UDL_Def;
Max_Deflection = P1_Max + UDL_Max
elseif (double_loadings == 4); % for both end Point load and TDL load.
Deflection = P1_Def + TDL_Def;
Max_Deflection = P1_Max + TDL_Max
elseif (double_loadings == 5);% for both end Point load and Mo.
Deflection = P1_Def + MO_Def;
Max_Deflection = P1_Max + MO_Max
end
elseif (Loading == 2); %intermediate loading
double_loadings = input('Enter 1 for P2, 2 for P2+UDL, 3 for P2+TDL, 4 for P2+Mo =')
if(double_loadings == 1); % a single intermediate load(P2)
Range_across_beam_length = input('Enter 1 for 0<x<a range, Enter 2 for a<x<L range = ');
if (Range_across_beam_length == 1); % a single intermediate load(P2)
Deflection = P2_Def;
elseif (Range_across_beam_length == 2); % a single intermediate load(P2)
Deflection = P22_Def;
end
Max_Deflection = P2_Max
elseif(double_loadings == 2); % both intermediate(P2) load and UDL
Range_across_beam_length = input('Enter 1 for 0<x<a range, Enter 2 for a<x<L range = ');
if (Range_across_beam_length == 1);% both intermediate(P2) load and UDL 0<x<a range
Deflection = P2_Def + UDL_Def;
elseif (Range_across_beam_length == 2); % both intermediate(P2) load and UDL a<x<L range
Deflection = P22_Def + UDL_Def;
end
Max_Deflection = P2_Max + UDL_Max
elseif(double_loadings == 3) % both intermediate load(P2) and TDL
Range_across_beam_length = input('Enter 1 for 0<x<a range, Enter 2 for a<x<L range = ');
if (Range_across_beam_length == 1);
Deflection = P2_Def + TDL_Def;
elseif Range_across_beam_length == 2
Deflection = P22_Def + TDL_Def;
end
Max_Deflection = P2_Max + TDL_Max
elseif(double_loadings == 4);
Range_across_beam_length = input('Enter 1 for 0<x<a range, Enter 2 for a<x<L range = ');
if (Range_across_beam_length == 1); % both intermediate(P2) load and MO
Deflection = P2_Def + MO_Def;
elseif Range_across_beam_length == 2 % both intermediate(P22) load and MO
Deflection = P22_Def + MO_Def;
end
Max_Deflection = P2_Max + MO_Max
end
elseif (Loading == 3); % UDL on Cantilever beam
double_loadings = input('Enter 1 for UDL, 2 for UDL+TDL, 3 for UDL+Mo =')
if(double_loadings == 1);% for a UDL the cantilever beam
Deflection = UDL_Def;
Max_Deflection = UDL_Max
elseif (double_loadings == 2);% for both UDL and TDL on the cantilever beam
Deflection = UDL_Def + TDL_Def;
Max_Deflection = UDL_Max + TDL_Max
elseif (double_loadings == 2);% for both UDL and MO on the cantilever beam
Deflection = UDL_Def + MO_Def;
Max_Deflection = UDL_Max + MO_Max
end
elseif (Loading == 4); %TDL on a cantilever beam
double_loadings = input('Enter 1 for TDL, 2 for TDL+MO, =')
if(double_loadings == 1);% for a TDL on the cantilever beam
Deflection = TDL_Def;
Max_Deflection = TDL_Max
elseif(double_loadings == 2);% for both TDL and MO on the cantilever beam
Deflection = TDL_Def + MO_Def;
Max_Deflection = TDL_Max + MO_Max
end
elseif (Loading == 5); % moment(MO) on a cantilever beam
Deflection = MO_Def;
Max_Deflection = MO_Max
end
Deflection_Circular = Deflection(1);
Max_Deflection_Circular = Max_Deflection(1);
Deflection_rectangular = Deflection(2);
Max_Deflection_rectangular = Max_Deflection(2);
Deflection_square = Deflection(3);
Max_Deflection_square = Max_Deflection(3);
Deflection_I_Section = Deflection(4);
Max_Deflection_I_Section = Max_Deflection(4);
Deflection_Hollow_cylindrical = Deflection(5);
Max_Deflection_Hollow_cylindrical = Max_Deflection(5);
plot(x, Deflection(1), x, Deflection(2), x, Deflection(3),x, Deflection(4), x, Deflection(5));grid
legend({'y=Deflection(1)','y=Deflection(2)','y=Deflection(3)','y=Deflection(4)','y=Deflection(5)'},'Location','southwest')
xlabel('X Length along the beam (mm)')
ylabel('Deflection(mm), Slope (rad)')
title('Cantilever Beam Deflection ')

Answers (0)

Categories

Products

Asked:

on 5 Dec 2020

Edited:

on 5 Dec 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!