find the initial temperature of the wall as a function of position in matlab

To find the initial temperature of a wall as a function of position in Matlab, you would need to specify the initial conditions and the governing heat transfer equation for the wall.

Here is an example code using the one-dimensional heat transfer equation to find the initial temperature distribution along a wall with constant thermal conductivity, density and specific heat:

main.m
% Define constants and parameters
k = 1; % thermal conductivity (W/mK)
rho = 1000; % density (kg/m^3)
c = 1000; % specific heat (J/kgK)
L = 1; % length of wall (m)
dx = 0.01; % spatial step size (m)

% Define initial conditions
t0 = 293; % initial temperature (K)

% Define heat transfer equation
syms x t T(x,t)
eqn = rho*c*diff(T,t) == k*diff(T,x,2);

% Define boundary conditions
BC1 = T(0,t) == 293; % temperature at x = 0 is 293 K
BC2 = T(L,t) == 293; % temperature at x = L is 293 K
IC = T(x,0) == t0; % initial temperature

% Solve the heat transfer equation using pdepe
m = 0; % no heat generation
sol = pdepe(m,eqn,IC,BC1,BC2,[],[0:dx:L]);

% Extract initial temperature distribution
T0 = sol(end,:)';

% Plot initial temperature distribution
x = 0:dx:L;
plot(x,T0)
xlabel('Position (m)')
ylabel('Temperature (K)')
title('Initial Temperature Distribution')
866 chars
33 lines

This code uses the pdepe function in Matlab to solve the heat transfer equation for the wall, and then extracts the final temperature distribution at time t = 0 to get the initial temperature distribution.

Note: This code assumes that the wall is initially at a uniform temperature t0, and that there is no heat flux across the wall at t = 0. You may need to modify the code for different initial conditions or boundary conditions.

gistlibby LogSnag