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?
Final_Project/Plot3a.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
97 lines (97 sloc)
3.06 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
function Plot3a | |
b=0.1; | |
h=0.01; | |
I=(b*(h^3))/12; | |
E=70E9; | |
n=6; | |
delta=1/n; | |
iter=0; | |
P=0; | |
w=zeros(1,5); | |
w2=zeros(1,5); | |
w3=zeros(1,5); | |
w4=zeros(1,5); | |
for q=[1,10,20,30,50] | |
iter=iter+1; | |
z=((delta.^4)*q)/(E*I); | |
OD=-4-(((P*(1/(n^2)))/(E*I)));% finds off diagonal term | |
D=6+((P*(2*(1/(n^2))))/(E*I));%finds Diagonal Term | |
OffDiagVect=ones((n-2),1)*OD;%Creates off diagonal vector | |
DiagVect=ones(n-1,1)*D;%Creates the diagonal vector | |
Off_Off_Diag=ones((n-3),1);%Creates the Off-Off diagonal Vector | |
A=diag(OffDiagVect,-1)+ diag(DiagVect)+diag(OffDiagVect,1)+diag(Off_Off_Diag,2)+diag(Off_Off_Diag,-2); | |
A(1,1)=5+((P*(2*(1/(n^2))))/(E*I));%forms Matrix A | |
A((n-1),(n-1))=5+((P*(2*(1/(n^2))))/(E*I)); | |
B=[z;z;z;z;z];%forms Matrix B | |
W=A\B;%Solves for deflection | |
maxw=max(-W); | |
w(iter)= -maxw; | |
end | |
q=[1,10,20,30,50]; | |
plot(q,w) | |
iter=0; | |
P=100;%For P=100 | |
for q=[1,10,20,30,50] | |
iter=iter+1; | |
z=((delta.^4)*q)/(E*I); | |
OD=-4-(((P*(1/(n^2)))/(E*I)));%finds off diagonal term | |
D=6+((P*(2*(1/(n^2))))/(E*I));%finds Diagonal Term | |
OffDiagVect=ones((n-2),1)*OD;%Creates the off diagonal vector | |
DiagVect=ones(n-1,1)*D;%Creates the diagonal vector | |
Off_Off_Diag=ones((n-3),1);%Creates the Off-Off diagonal Vector | |
A=diag(OffDiagVect,-1)+ diag(DiagVect)+diag(OffDiagVect,1)+diag(Off_Off_Diag,2)+diag(Off_Off_Diag,-2); | |
A(1,1)=5+((P*(2*(1/(n^2))))/(E*I));%forms Matrix A | |
A((n-1),(n-1))=5+((P*(2*(1/(n^2))))/(E*I)); | |
B=[z;z;z;z;z];%forms Matrix B | |
W=A\B;%Solves for deflection | |
maxw=max(-W); | |
w2(iter)= -maxw; | |
end | |
q=[1,10,20,30,50]; | |
hold on | |
plot(q,w2) | |
iter=0; | |
P=200;%For P=200 | |
for q=[1,10,20,30,50] | |
iter=iter+1; | |
z=((delta.^4)*q)/(E*I); | |
OD=-4-(((P*(1/(n^2)))/(E*I)));%finds off diagonal term | |
D=6+((P*(2*(1/(n^2))))/(E*I));%finds Diagonal Term | |
OffDiagVect=ones((n-2),1)*OD;%Creates the off diagonal vector | |
DiagVect=ones(n-1,1)*D;%Creates the diagonal vector | |
Off_Off_Diag=ones((n-3),1);%Creates the Off-Off diagonal Vector | |
A=diag(OffDiagVect,-1)+ diag(DiagVect)+diag(OffDiagVect,1)+diag(Off_Off_Diag,2)+diag(Off_Off_Diag,-2); | |
A(1,1)=5+((P*(2*(1/(n^2))))/(E*I));%Creates Matrix A | |
A((n-1),(n-1))=5+((P*(2*(1/(n^2))))/(E*I)); | |
B=[z;z;z;z;z];%Creates Matrix B | |
W=A\B; | |
maxw=max(-W); | |
w3(iter)= -maxw;%Solves for deflection | |
end | |
q=[1,10,20,30,50]; | |
plot(q,w3) | |
iter=0; | |
P=300;%For P=300 | |
for q=[1,10,20,30,50] | |
iter=iter+1; | |
z=((delta.^4)*q)/(E*I); | |
OD=-4-(((P*(1/(n^2)))/(E*I)));%finds off diagonal term | |
D=6+((P*(2*(1/(n^2))))/(E*I));%finds Diagonal Term | |
OffDiagVect=ones((n-2),1)*OD;%Creates off diagonal vector | |
DiagVect=ones(n-1,1)*D;%Creates diagonal vector | |
Off_Off_Diag=ones((n-3),1);%Creates Off-Off diagonal Vector | |
A=diag(OffDiagVect,-1)+ diag(DiagVect)+diag(OffDiagVect,1)+diag(Off_Off_Diag,2)+diag(Off_Off_Diag,-2); | |
A(1,1)=5+((P*(2*(1/(n^2))))/(E*I));%forms Matrix A | |
A((n-1),(n-1))=5+((P*(2*(1/(n^2))))/(E*I)); | |
B=[z;z;z;z;z];%forms Matrix B | |
W=A\B;%Solves for deflection | |
maxw=max(-W); | |
w4(iter)= -maxw; | |
end | |
q=[1,10,20,30,50]; | |
plot(q,w4) | |
title('Beam Deflection P>0 for 6 segments') | |
xlabel('Loading (N/m)') | |
ylabel('Deflection') | |
legend('P=0', 'P=100', 'P=200', 'P=300') | |
end |