Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
data upload
- Loading branch information
Showing
9 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
N= [5,6,10]-1; | ||
|
||
%Given constant values | ||
E=76e9; | ||
I=4e-9; | ||
L=5; | ||
|
||
%For loop that creates: | ||
%1 - the lambda values | ||
%2 - number of segments | ||
%3 - number of eignvalues | ||
i=1; | ||
for m=N | ||
Dx=L/m; | ||
p=10/(E*I); | ||
a=Dx^2*p^2-2; | ||
m=diag(ones(1,m-1),-1)+diag(a*ones(1,m))+ diag(ones(1,m-1),1) | ||
e=eig(m); | ||
i; | ||
maxLam(i)= max(e); | ||
minLam(i)=min(e); | ||
i=i+1; | ||
end | ||
|
||
maxLam' | ||
minLam' | ||
N' | ||
nodes = N+1; | ||
nodes' | ||
|
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
%This script solves the ODE Equation for the | ||
%Spring Mass System given in the HW | ||
|
||
%Values of System | ||
stiff = [10,20,20,10]; | ||
mass= [1;2;4;]; | ||
|
||
%ODE Equations | ||
f1=[-1*(stiff(1)+stiff(2)), stiff(2), 0]; | ||
f2=[stiff(2), -1*(stiff(2)+stiff(3)), stiff(3)]; | ||
f3=[0,stiff(3), -1*(stiff(3)+stiff(4))]; | ||
|
||
K= [f1;f2;f3]; | ||
K= -1*K; | ||
|
||
M= diag(mass); | ||
|
||
K_tilde= (M^(-1/2))*(K)*(M^(-1/2)); | ||
|
||
%Final lambda and omega | ||
e=eig(K_tilde) | ||
|
||
w= sqrt(e) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function [ud, uo, lo ] = lu_tridiag( e,f,g ) | ||
|
||
|
||
%This function carries out the LU decomposition | ||
% It takes in 3 vectors: | ||
% e subdiagonal, f diagonal, g superdiagonal | ||
|
||
A=diag(f)+diag(g,1)+diag(e,-1); | ||
B=eye(length(f)); | ||
|
||
for j=1:length(e) | ||
|
||
x=A(j+1,j)/A(j,j); | ||
A(j+1,j)= (-e(j)/f(j))*f(j)+e(j); | ||
A(j+1,j+1)= (-x)*g(j)+f(j+1); | ||
B(j+1,j)=x; | ||
ud(1)=A(1,1); | ||
ud(j+1)= A(j+1,j+1); | ||
uo(j)=A(j,j+1); | ||
lo(j)=B(j+1,j); | ||
end | ||
|
||
%this will display the function results | ||
disp(ud) | ||
disp(uo) | ||
disp(lo) | ||
|
||
end | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
function [ud, uo, lo ] = lu_tridiag( e,f,g ) | ||
|
||
|
||
%This function carries out the LU decomposition | ||
% It takes in 3 vectors: | ||
% e subdiagonal, f diagonal, g superdiagonal | ||
|
||
A=diag(f)+diag(g,1)+diag(e,-1); | ||
B=eye(length(f)); | ||
|
||
for j=1:length(e) | ||
|
||
x=A(j+1,j)/A(j,j); | ||
A(j+1,j)= (-e(j)/f(j))*f(j)+e(j); | ||
A(j+1,j+1)= (-x)*g(j)+f(j+1); | ||
B(j+1,j)=x; | ||
lo(j)=B(j+1,j); | ||
ud(1)=A(1,1); | ||
ud(j+1)= A(j+1,j+1); | ||
uo(j)=A(j,j+1); | ||
|
||
end | ||
|
||
end | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function [x]=solve_tridiag(ud,uo,lo,b) | ||
|
||
%Input: output of lu_tridiag function | ||
%Output: x vector (Ax = B) | ||
|
||
M=ones(1,length(ud)); % initialisation | ||
|
||
for n = 1:(length(ud)-1) | ||
M(1)=b(1); | ||
M(n+1)= b(n+1)-(M(n)*lo(n)); | ||
end | ||
|
||
|
||
x=ones(1,length(ud)); % initialisation | ||
|
||
for k =(length(ud):-1:2) | ||
x(length(ud))=M(length(ud))/ud(length(ud)); | ||
x(k-1)= (M(k-1)-(uo(k-1)*x(k)))/(ud(k-1)); | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
function [x]=solve_tridiag(ud,uo,lo,b) %Input: output of lu_tridiag function | ||
%Output: x vector (Ax = B) | ||
|
||
T=ones(1,length(ud)); % initialisation | ||
|
||
for n = 1:(length(ud)-1) | ||
|
||
T(1)=b(1); | ||
|
||
T(n+1)= b(n+1)-(T(n)*lo(n)); | ||
end | ||
|
||
|
||
x=ones(1,length(ud)); % initialisation | ||
|
||
|
||
|
||
|
||
for k =(length(ud):-1:2) | ||
|
||
x(length(ud))=T(length(ud))/ud(length(ud)); | ||
|
||
x(k-1)= (T(k-1)-(uo(k-1)*x(k)))/(ud(k-1)); | ||
|
||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
rand('seed',1); | ||
|
||
for i = 3:10 | ||
e=sort(randi(6,[i-1,1])); | ||
f=sort(randi(10,[i,1])); | ||
g=sort(randi(9,[i-1,1])); | ||
eval(['A',int2str(i),'=diag(f)+diag(e,-1)+diag(g,1);']); | ||
end |