Permalink
Cannot retrieve contributors at this time
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?
me3255_group5/Plot_20P.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
130 lines (112 sloc)
3.62 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%Plot of central_diff20P code for P =0,100,200,300 and for q=1,10,20,30,50 | |
b=0.1; %width of beam | |
h=0.01;%height of beam | |
I=(b*(h^3))/12; %Second MOI | |
E=70E9; %Modulus of Elasticity | |
n=20; %Number of segments | |
x=1/n; %segment equivalent | |
%For loop for P=0 | |
i=0; | |
P=0; | |
w0=zeros(1,5); %Vector of zeros for displacement when P=0 | |
w100=zeros(1,5); %Vector of zeroes for displacement when P=100 | |
w200=zeros(1,5); %Vector of zeroes for displacement when P=200 | |
w300=zeros(1,5); %Vector of zeroes for displacement when P=300 | |
for q=[1,10,20,30,50] | |
i=i+1; | |
z=((x.^4)*q)/(E*I); %differentiation used to solve for displacement | |
Off_Diag=-4-(((P*(1/(n^2)))/(E*I))); %Off Diagonal value | |
Diag=6+((P*(2*(1/(n^2))))/(E*I)); %Diagonal value | |
ODV = ones((n-2),1)*Off_Diag; %Off Diagonal vector | |
DV = ones(n-1,1)*Diag; %Diagonal vector | |
OOD = ones((n-3),1); %Off off diagonal vector | |
%Generate Matrix X | |
X=diag(ODV,-1)+diag(DV)+diag(ODV,1)+diag(OOD,2)+diag(OOD,-2); | |
X(1,1)= 5+((P*(2*(1/(n^2))))/(E*I)); | |
X((n-1),(n-1))=5+((P*(2*(1/(n^2))))/(E*I)); | |
%Generate Matrix Y | |
Y=[z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z]; | |
%Solve for deflection Matrix | |
W=X\Y; | |
maxw=max(-W); | |
w0(i)=-maxw; | |
end | |
q=[1,10,20,30,50]; | |
plot(q,w0) | |
%For loop for P=100 | |
i=0; | |
P=100; | |
for q=[1,10,20,30,50] | |
i=i+1; | |
z=((x.^4)*q)/(E*I); %differentiation used to solve for displacement | |
Off_Diag=-4-(((P*(1/(n^2)))/(E*I))); %Off Diagonal value | |
Diag=6+((P*(2*(1/(n^2))))/(E*I)); %Diagonal value | |
ODV = ones((n-2),1)*Off_Diag; %Off Diagonal vector | |
DV = ones(n-1,1)*Diag; %Diagonal vector | |
OOD = ones((n-3),1); %Off off diagonal vector | |
%Generate Matrix X | |
X=diag(ODV,-1)+ diag(DV)+diag(ODV,1)+diag(OOD,2)+diag(OOD,-2); | |
X(1,1)= 5+((P*(2*(1/(n^2))))/(E*I)); | |
X((n-1),(n-1))=5+((P*(2*(1/(n^2))))/(E*I)); | |
%Generate Matrix Y | |
Y=[z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z]; | |
%Solve for deflection Matrix | |
W=X\Y; | |
maxw=max(-W); | |
w100(i)=-maxw; | |
end | |
q=[1,10,20,30,50]; | |
hold on | |
plot(q,w100) | |
%For loop for P=200 | |
i=0; | |
P=200; | |
for q=[1,10,20,30,50] | |
i=i+1; | |
z=((x.^4)*q)/(E*I); %differentiation used to solve for displacement | |
Off_Diag=-4-(((P*(1/(n^2)))/(E*I))); %Off Diagonal value | |
Diag=6+((P*(2*(1/(n^2))))/(E*I)); %Diagonal value | |
ODV = ones((n-2),1)*Off_Diag; %Off Diagonal vector | |
DV = ones(n-1,1)*Diag; %Diagonal vector | |
OOD = ones((n-3),1); %Off off diagonal vector | |
%Generate Matrix X | |
X=diag(ODV,-1)+ diag(DV)+diag(ODV,1)+diag(OOD,2)+diag(OOD,-2); | |
X(1,1)= 5+((P*(2*(1/(n^2))))/(E*I)); | |
X((n-1),(n-1))=5+((P*(2*(1/(n^2))))/(E*I)); | |
%Generate Matrix Y | |
Y=[z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z]; | |
%Solve for deflection Matrix | |
W=X\Y; | |
maxw=max(-W); | |
w200(i)=-maxw; | |
end | |
q=[1,10,20,30,50]; | |
plot(q,w200) | |
%For loop for P=300 | |
i=0; | |
P=300; | |
for q=[1,10,20,30,50] | |
i=i+1; | |
z=((x.^4)*q)/(E*I); %differentiation used to solve for displacement | |
Off_Diag=-4-(((P*(1/(n^2)))/(E*I))); %Off Diagonal value | |
Diag=6+((P*(2*(1/(n^2))))/(E*I)); %Diagonal value | |
ODV = ones((n-2),1)*Off_Diag; %Off Diagonal vector | |
DV = ones(n-1,1)*Diag; %Diagonal vector | |
OOD = ones((n-3),1); %Off off diagonal vector | |
%Generate Matrix X | |
X=diag(ODV,-1)+ diag(DV)+diag(ODV,1)+diag(OOD,2)+diag(OOD,-2); | |
X(1,1)= 5+((P*(2*(1/(n^2))))/(E*I)); | |
X((n-1),(n-1))=5+((P*(2*(1/(n^2))))/(E*I)); | |
%Generate Matrix Y | |
Y=[z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z;z]; | |
%Solve for deflection Matrix | |
W=X\Y; | |
maxw=max(-W); | |
w300(i)=-maxw; | |
end | |
q=[1,10,20,30,50]; | |
plot(q,w300) | |
title('Distributed Loading versus Max Beam Deflection for 20 Segment Beam') | |
xlabel('Loading q (N/m)') | |
ylabel('Deflection dx') | |
legend('P=0', 'P=100', 'P=200', 'P=300') |