Skip to content
Permalink
a1ff183191
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
104 lines (96 sloc) 2.65 KB
% The code uses the central difference approximation used from 2a-c to find
% the max deflection in the beam for each segment split and plot the
% distributed load q against the max deflection dx.
%For loop for six segments to find max deflection
n=0;
for q = [1,10,20,30,50]
n=n+1;
x=1/6; %splits up beam into six
b=0.1; %width of beam
E=70E9; %Young's modulus
h=0.01;%height of beam
I=(b*(h^3))/12; %Second MOI
z=((x.^4)*q)/(E*I); %differentiation used to solve for displacement
Seg6 =[5,-4,1,0,0;
-4,6,-4,1,0;
1,-4,6,-4,1;
0,1,-4,6,-4;
0,0,1,-4,5];
Y=[z;z;z;z;z];
B=Seg6\Y;
B_3=B;
max_def3=max(B_3);
X6(n) = max_def3;
end
%For loop for ten segments to find max deflection
n=0;
for q = [1,10,20,30,50]
n=n+1;
x2=1/10; %splits up beam into ten
b=0.1; %width of beam
E=70E9; %Young's modulus
h=0.01;%height of beam
I=(b*(h^3))/12; %Second MOI
z=((x2.^4)*q)/(E*I); %differentiation used to solve for displacement
Seg10= [5,-4,1,0,0,0,0,0,0;
-4,6,-4,1,0,0,0,0,0;
1,-4,6,-4,1,0,0,0,0;
0,1,-4,6,-4,1,0,0,0;
0,0,1,-4,6,-4,1,0,0;
0,0,0,1,-4,6,-4,1,0;
0,0,0,0,1,-4,6,-4,1;
0,0,0,0,0,1,-4,6,-4;
0,0,0,0,0,0,1,-4,5];
Y=[z;z;z;z;z;z;z;z;z];
B=Seg10\Y;
B_2=B;
max_def2=max(B_2);
X10(n)=max_def2;
end
%For loop for twenty segments to find max deflection
n=0;
for q = [1,10,20,30,50]
n=n+1;
x3=1/20; %splits up beam into twenty
b=0.1; %width of beam
E=70E9; %Young's modulus
h=0.01;%height of beam
I=(b*(h^3))/12; %Second MOI
z=((x3.^4)*q)/(E*I); %differentiation used to solve for displacement
Seg20= [5,-4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
-4,6,-4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
1,-4,6,-4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
0,1,-4,6,-4,1,0,0,0,0,0,0,0,0,0,0,0,0,0;
0,0,1,-4,6,-4,1,0,0,0,0,0,0,0,0,0,0,0,0;
0,0,0,1,-4,6,-4,1,0,0,0,0,0,0,0,0,0,0,0;
0,0,0,0,1,-4,6,-4,1,0,0,0,0,0,0,0,0,0,0;
0,0,0,0,0,1,-4,6,-4,1,0,0,0,0,0,0,0,0,0;
0,0,0,0,0,0,1,-4,6,-4,1,0,0,0,0,0,0,0,0;
0,0,0,0,0,0,0,1,-4,6,-4,1,0,0,0,0,0,0,0;
0,0,0,0,0,0,0,0,1,-4,6,-4,1,0,0,0,0,0,0;
0,0,0,0,0,0,0,0,0,1,-4,6,-4,1,0,0,0,0,0;
0,0,0,0,0,0,0,0,0,0,1,-4,6,-4,1,0,0,0,0;
0,0,0,0,0,0,0,0,0,0,0,1,-4,6,-4,1,0,0,0;
0,0,0,0,0,0,0,0,0,0,0,0,1,-4,6,-4,1,0,0;
0,0,0,0,0,0,0,0,0,0,0,0,0,1,-4,6,-4,1,0;
0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-4,6,-4,1;
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-4,6,-4;
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-4,5];
Y=[z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z];
B=Seg20\Y;
B_3=B;
max_def3=max(B_3);
X20(n) = max_def3;
end
%Plot q vs dx
setdefaults
q=[1,10,20,30,50] ;
title ('Deflection vs Distributed Load')
xlabel('q (N/m)')
ylabel('dx')
hold on
plot(q,X6)
plot(q,X10)
plot(q,X20)
legend('6 segments', '10 segments', '20 segments')
hold off