
unsteady problem
xmin = 0;
xmax = 0.2;
N = 10; # Nodes to be made
dx = (xmaxxmin)/(N1);
x = xmin:dx:xmax;
dt = 1e3 # time step
tmax = 0.5;
t = 0:dt:tmax;alpha = 0.05; # Material Property defined
# Initial Boundary Condition def
Tcurrent = ones(1,N)*50; # Temp is initiated from step 1
Tb = 300;
Ttip = 50;# Solution
d = alpha * dt/dx^2for j = 2:length(t)
T = Tcurrent;
for i=1:N
if i==1
T(i) = Tb;endif i==N
T(i) = Ttip;
else
T(i) = T(i)+d*(T(i+1)2*T(i)+T(i1));
end
end
Tcurrent = T;
time = j*dt;
plot(x,Tcurrent)xlabel(‘Length of Rod [m]’,’Font Size’,14)
ylabel(‘Temperature [{o}C]’,’Font Size’,14)
set(gca,’Fontsize’,16)
str1 = sprintf(‘Value of d = %d’,d);
str2 = sprintf(‘Time value = %d’s,time);
text(0.15,150,str1,’Fontsize’,14);
text(0.15,150,str2,’Fontsize’,14);
shg
pause(0.01)
end
i could not see plots .
Log in to reply.