lu_tridiag is a function that does L U decomposition on a 3x3 matrix and can be found in the files folder. solve_tridiag is a function that solves for x given A*x = b and can be found in the files folder.
lu_tridiag can only be conducted on 3x3 matrix. To evaluate solve_tridiag with matrices lager than 3x3 a script had to be made to get the diagonals of matrices for use in solve_tridiag. This can be found in large_mat_eval.m
###Table of errors made from backslash operator
Size norm_error
____ __________
3 1.1547
4 1.5
5 1.6
6 2.0412
7 2.2678
8 2.315
9 2.6667
10 2.846
###Finding Eigenvalues and Natural Frequencies
The following code solves the 3-DOF mass spring system's eigenvalues and natural frequencies
% Assigns mass values kg
m1 = 1;
m2 = 2;
m3 = 4;
% Assigns spring constants N/m
k1 = 10;
k2 = 20;
k3 = 20;
k4 = 10;
% Creates mass matrix
m = [m1 0 0; 0 m2 0; 0 0 m3];
% Creates spring constant matrix
k = [k1+k2, -k2, 0; -k2, k2+k3, -k3; 0, -k3, k3+k4];
lam = eig(k,m) % outputs eigenvalues
omega = lam.^.5 % outputs natural frequency rad/s
OUTPUT
lam =
2.5690
14.4090
40.5220
omega =
1.6028
3.7959
6.3657
Code
% Inputs
L = 5; % meters
segments = 5;
%constants
E = 76*10^9; % Pa
I = 4*10^-8; % m^4
nodes = segments-1;
k = zeros(nodes,nodes);
dx = (L/segments)^2;
scale = 1/dx;
matrix = scale*(2*eye(nodes) + diag(-1*ones(1, nodes-1),1) + diag(-1*ones(1, nodes-1),-1));
lambda = eig(matrix)
Table
Num_Segments Largest Smallest Num_Eigen
____________ _______ ________ _________
5 3.618 0.382 4
6 3.7321 0.2679 5
10 3.9021 0.0979 9
As dx approaches zero the eigenvalues increase in the opposite magnitude (become 10^x times larger)