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 Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by