Skip to content

Commit bee7f6c

Browse files
authored
Add Tridiagonal LU Decomposition example to README
1 parent ae38084 commit bee7f6c

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
11
# misc-matlab-scripts
2+
23
A collection of MATLAB scripts.
34

45
### Table of Contents
5-
1. [Tridiagonal LU Decomposition Matrix Solver](#Tridiagonal-LU-Decomposition-Matrix-Solver)
6+
7+
1. [Tridiagonal LU Decomposition Matrix Solver](#Tridiagonal-LU-Decomposition-Matrix-Solver)
8+
a. [Example usage](#Example-usage)
69

710
### Tridiagonal LU Decomposition Matrix Solver
11+
812
This script solves `Ax = d` for `x` using LU decomposition for the square tridiagonal matrix `A`.
913

10-
A square tridiagonal matrix `A` has the following structure:\
14+
A square tridiagonal matrix `A` has the following structure:
1115
<img src="https://raw.githubusercontent.com/onezerosix/misc-matlab-scripts/master/pictures/tridiag_lu_decomp_A.png" width="40%" alt="matrix A">
1216

13-
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:\
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:
1418
<img src="https://raw.githubusercontent.com/onezerosix/misc-matlab-scripts/master/pictures/tridiag_lu_decomp_A_conditions.png" width="50%" alt="matrix A conditions">
1519

16-
The output includes vector `x` and vector `z` such that `z = Ux`. It also includes vectors `alpha` and `beta` such that:\
20+
The output includes vector `x` and vector `z` such that `z = Ux`. It also includes vectors `alpha` and `beta` such that:
1721
<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)