diff options
author | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2020-02-16 14:26:55 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2020-02-16 14:26:55 +0700 |
commit | 82e6cf7d1046d6cee16f7e8b044ec33e7ec6c4b7 (patch) | |
tree | f7b7ae0bce69070c47a1b31a85bd2bc69dfecf09 /usth/MATH2.4/project/heatrans.m | |
parent | 29d1001e2e21eff289bff23412e284c8b2e44595 (diff) | |
download | cp-82e6cf7d1046d6cee16f7e8b044ec33e7ec6c4b7.tar.gz |
[usth] Numerical Method is MATH2.4
Diffstat (limited to 'usth/MATH2.4/project/heatrans.m')
-rw-r--r-- | usth/MATH2.4/project/heatrans.m | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/usth/MATH2.4/project/heatrans.m b/usth/MATH2.4/project/heatrans.m new file mode 100644 index 0000000..d5d2e04 --- /dev/null +++ b/usth/MATH2.4/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 |