Help with Central Difference Code

I am trying to create a code to solve for the heat transfer through an exhaust system. I have inserted a picture below of a similar simplified problem. Mainly, I need help with the iterations in the 4 boxes where it says Node 1, Node 2, Node 3, and Node 4. I need to start the iterations with putting in the temperature for T0 and have the iterations end when it reaches Tn. If possible, I need the output of the temperatures (340, 40, 40, 440) to be in the form of a vector. I also need to extract the coefficients attached to T1, T2, T3, and T4 from each set of equations and put those in the form of a matrix. The very bottom of the picture shows what information is needed. This example is quite a bit simplified and is easy to do by hand. However, for the real problem I am doing, I will be working with matrices that are 250x250, 500x500, 1000x1000, etc and it will be too tedious to do all of that by hand. I would greatly appreciate any help in setting up a code. Thank you in advance!

답변 (1개)

John D'Errico
John D'Errico 2017년 12월 11일

0 개 추천

You need to learn to use MATLAB, creating arrays programmatically.
So just write a loop that creates those coefficients on the fly. Preallocate your matrix of course. Better yet, create the coefficients as a vector of coefficients, then use tools like spdiags to create the matrix.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2017년 12월 11일

답변:

2017년 12월 11일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by