Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
data upload
  • Loading branch information
yaa16116 committed Mar 30, 2017
1 parent 48b296e commit 50f1160
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 0 deletions.
Binary file added Curvature of slender element.JPG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions Eigen_Values.m
@@ -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 added Spring-mass system.pdf
Binary file not shown.
23 changes: 23 additions & 0 deletions Spring_Mass.m
@@ -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)
29 changes: 29 additions & 0 deletions lu_tridiag.asv
@@ -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

25 changes: 25 additions & 0 deletions lu_tridiag.m
@@ -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

19 changes: 19 additions & 0 deletions solve_tridiag.asv
@@ -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
25 changes: 25 additions & 0 deletions solve_tridiag.m
@@ -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
8 changes: 8 additions & 0 deletions test_array.m
@@ -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

0 comments on commit 50f1160

Please sign in to comment.