Elegant way to calculate heat flux for heat equation

2 views (last 30 days)
Hi.
I want to calculate heat flux in two-diemnsional, uniform domain using Fourier equation:
I have four vectors: X - containg x coordinates of domain points, Y - containg y coordinates of domain points, T - containg temperatures in specific points, K - containg values of heat conductivity in specific points. Dimension of X,Y,T,K is [nx*ny , 1]. I did it this way:
[px,py] = gradient(reshape(T,[nx,ny]),dx,dy);
qx = -qx .* reshape(K,[nx,ny]);
qy = -qy .* reshape(K,[nx,ny]);
qx = qx(:);
qy = qy(:);
which I find not very elegant, I even did not use X,Y vectors. dx,dy are spacings of uniform domain and nx, ny are number of points in each direction. Do you have better idea?
Kind regards
  1 Comment
Bjorn Gustavsson
Bjorn Gustavsson on 17 Sep 2021
Why do you find this not elegant?
If your coordinate matrices arent uniformly spaced you can use the first row-and column of X and Y in place of dx and dy. (in that case you might prefer to use a properly calculated central difference instead of the wonky one in gradient.)

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!