Prev: Possible Issue with Jan Simon's "Shuffle" Program
Next: Creating mesh and using contourf for temperature
From: Abe Devinko on 13 Jul 2010 06:48 Hi all I wrote a matlab code to find 2D temperature distribution in a plate that is 0.4m wide by 0.7m tall. There are 40 nodes all together. I used the energy balance method and determined the temperature on each node using the matrix inversion method. Now I have temperature of each of the 40 nodes in T, and wish to plot a temperature distribution in the plate per location. How would I go about doing that? I know I will have to store the temperature profile in a 2D matrix, and then create a meshgrid according to dimensions of the plate (my delta is 0.1 in x and y direction). Here's the diagram of the problem. [IMG] http://i25.tinypic.com/2v0zi8m.jpg [/IMG] I know i have to use meshgrid command to have temp for each node displayed at the right location on the plate, but I am not very familiar with how to do it. Here's my code. clc clear all %Block & mesh size Lx = 0.4; % Width of block in x-direction (m) Ly = 0.7; % Height of block in y-direction (m) Ex = Lx/0.1; % Number of elements in x-direction Ey = Ly/0.1; % Number of elements in y-direction dx = Lx/Ex; % Spacing in x-direction dy = Ly/Ey; % Spacing in y-direction Nx = Ex+1; % Number of nodes in x-direction Ny = Ey+1; % Number of nodes in y-direction x = 0:dx:Lx; % Grid in x-direction y = 0:dy:Ly; % Grid in y-direction %Allocate storage space N = Nx*Ny; a = zeros(N,N); b = zeros(N,1); %Material Properties & Constants k = 50; % Thermal conductivity of block (W/m-K) h = 1000; % Heat transfer coeff (W/m^2-K) Tinf = 293.15; % Air temperature on top of block (K) Tw = 423.15; % Wall temperature of left and right edges (K) qdot = 5e5; % Uniform heat generation inside the block (W/m^3) Bi = (h*dx)/k; % Biot number c = (-qdot*dx^2)/k; d = 2*Bi*Tinf; %node(1) a(1,1)=-2*(Bi+1); a(1,2)=1; a(1,6)=1; b(1)=c-d; %node(5) a(5,5)=-2*(Bi+2); a(5,4)=2; a(5,10)=2; b(5)=c-d; .. .. .. .. %node(40) a(40,40)=-4; a(40,35)=2; a(40,39)=2; b(40)=c; T=a\b; Now I am lost in how to create a temperature distribution plot in the plate. I could create a new matrix, say u = zeros(Ny,Nx); and that will give me an 8 x 5 matrix. |