Hello I am trying to write a program to plot the temperature distribution in a insulated rod using the explicit Finite Central Difference Method and 1D Heat equation. The rod is heated on one end at 400k and exposed to ambient temperature on the right end at 300k. I am using a time of 1s, 11 grid points and a .002s time step. When I plot it gives me a crazy curve which isn't right. I think I am messing up my initial and boundary conditions. Here is my code.
L=1;t=1;k=.001;n=11;nt=500;dx=L/n;dt=.002;alpha=k*dt/dx^2;T0(1)=400;for j=1:nt for i=2:n T1(i)=T0(i)+alpha*(T0(i+1)-2*T0(i)+T0(i-1)); end T0=T1;endplot(x,T1)
Best Answer