Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c08a0d

Browse files
committed
2 parents 57b22ec + 8afb611 commit 1c08a0d

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# misc-matlab-scripts
2+
3+
A collection of MATLAB scripts.
4+
5+
### Table of Contents
6+
7+
1. [Tridiagonal LU Decomposition Matrix Solver](#Tridiagonal-LU-Decomposition-Matrix-Solver)
8+
a. [Example](#Example)
9+
10+
### Tridiagonal LU Decomposition Matrix Solver
11+
12+
This script solves `Ax = d` for `x` using LU decomposition for the square tridiagonal matrix `A`.
13+
14+
A square tridiagonal matrix `A` has the following structure:
15+
<img src="https://raw.githubusercontent.com/onezerosix/misc-matlab-scripts/master/pictures/tridiag_lu_decomp_A.png" width="40%" alt="matrix A">
16+
17+
The `a`, `b` and `c` variables are used as vector inputs for the script. The values must meet the following criteria for the script to work:
18+
<img src="https://raw.githubusercontent.com/onezerosix/misc-matlab-scripts/master/pictures/tridiag_lu_decomp_A_conditions.png" width="50%" alt="matrix A conditions">
19+
20+
The output includes vector `x` and vector `z` such that `z = Ux`. It also includes vectors `alpha` and `beta` such that:
21+
<img src="https://raw.githubusercontent.com/onezerosix/misc-matlab-scripts/master/pictures/tridiag_lu_decomp_LU.png" width="70%" alt="L and U matrices">
22+
23+
##### Example
24+
```
25+
>> [alpha, beta, z, x] = tridiag_lu_decomp([2;2;2;2;2], [1;1;1;1;1], [1;1;1;1;1], [3;4;4;4;3])
26+
27+
alpha =
28+
2.0000 1.5000 1.3333 1.2500 1.2000
29+
30+
beta =
31+
0 0.5000 0.6667 0.7500 0.8000
32+
33+
z =
34+
3.0000 2.5000 2.3333 2.2500 1.2000
35+
36+
x =
37+
1 1 1 1 1
38+
```

0 commit comments

Comments
 (0)