Solving Heat Transfer Problem In Matlab with Finite Difference Mesh

  • Context: MATLAB 
  • Thread starter Thread starter MattT1991
  • Start date Start date
  • Tags Tags
    Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
MattT1991
Messages
8
Reaction score
0
Hi everyone,

I am having a bit of a problem with Matlab. I am currently using a finite difference mesh to solve the heat equation across one spatial dimension - x and time. I had an water array with depth and time and a boundary condition given by heat transfer equations which set the top line. This ran perfectly fine downwards from 2 : end-1

I then added an array above it that was the same but had air properties. From this I set the bottom row to a boundary condition using the heat transfer equations and tried to run it the same way but upwards from end-1 : 2.

It will not work and just alters the bottom row. The second differentials from the finite difference model come up as 0 despite their consituent parts clearly not adding to 0 uppon logging.

(the model is trying to show heat interaction between an air layer sat on a water layer and heat transfer within the 2 layers in assumed to be conduction only)

Can anyone suggest a solution to this or a problem it may be?

Can MATLAB handle running upwards through a mesh?

Thanks for any help, ( I am happy to give you more information)

Matt
 
Physics news on Phys.org


If you want to step in the negative direction you need to tell MATLAB so.

Use: end-1 : -1: 2

That should work
 


Thanks, I will try it now

It didn't work. The only way I have been able to do it is by putting a new for loop in that runs a variable up the array and use that to work up the array but it looks a lot messier than it should be...
 
Last edited: