How to implement the Fourier series method of heat equation?
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
How to implement the Fourier series method of heat equation by using the same value of L,alpha,t_final,n,t0,t1s and t2s?
L=20;
alpha=0.23;
t_final=60;
n=20;
T0=20;
T1s=100;
T2s=0;
dx=L/n;
dt=2;
x=dx/2:dx:L-dx/2;
t = 0:dt:t_final;
nt = length(t);
T = zeros(n, nt);
T(:,1) = T0;
for j=1:nt-1
dTdt=zeros(n,1);
for i=2:n-1
dTdt(i) = alpha*(T(i+1,j)+T(i-1,j)-2*T(i,j))/dx^2;
end
dTdt(1) = alpha*(T(2,j)+T1s-2*T(1,j))/dx^2;
dTdt(n) = alpha*(T2s+T(n-1,j)-2*T(n,j))/dx^2;
T(:,j+1) = T(:,j) + dTdt*dt;
end
disp(T)
figure(1)
mesh(x,t,T.')
xlabel('Position (x)')
ylabel('Time (seconds)')
zlabel('Temparature, U(x,t)')
0 Commenti
Risposte (1)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!