How to implement the Fourier series method of heat equation?

조회 수: 9 (최근 30일)
Deck Zhan Sim
Deck Zhan Sim 2021년 1월 20일
답변: KSSV 2021년 1월 20일
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)')

답변 (1개)

KSSV
KSSV 2021년 1월 20일

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by