diff options
author | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2019-12-16 21:31:18 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2019-12-16 21:31:18 +0700 |
commit | e461df7573c2b7b7e26c965d8cf2d8e175d67378 (patch) | |
tree | 193b8439edac52c1749764395fe5f7787889eda9 /usth/MATH2.2/project/heatrans.m | |
parent | c1008fe39217be7f91f0ea23483e747bfbc5743e (diff) | |
download | cp-e461df7573c2b7b7e26c965d8cf2d8e175d67378.tar.gz |
[usth/MATH2.2] Numerical Methods
The future starts now.
Diffstat (limited to 'usth/MATH2.2/project/heatrans.m')
-rw-r--r-- | usth/MATH2.2/project/heatrans.m | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/usth/MATH2.2/project/heatrans.m b/usth/MATH2.2/project/heatrans.m new file mode 100644 index 0000000..d5d2e04 --- /dev/null +++ b/usth/MATH2.2/project/heatrans.m @@ -0,0 +1,15 @@ +function T = heatrans (cp, lambda, rho, Tg, Td, T0, L, dx, dt, N) + alpha = lambda / rho / cp; + beta = alpha * dt / dx^2; + M = round (L / dx); + side = repelem (beta, M); + A = diag (side, -1) + diag (repelem (1 - 2*beta, M + 1)) + diag (side, 1); + A(1, :) = A(end, :) = 0; + A(1, 1) = A(end, end) = 1; + + T = repelem (T0, M + 1); + [T(1) T(end)] = deal (Tg, Td); + for k = 2 : N + T(:, k) = A * T(:, k - 1); + end +end |