필터 지우기
필터 지우기

1-d heat transfer equation

조회 수: 3 (최근 30일)
chang hoon oh
chang hoon oh 2020년 6월 12일
답변: Walter Roberson 2020년 6월 12일
now i am wirte the heat equation code. it tisn't work ,,
L=10cm, dx=1cm n=10 T(11,200)
the initial condition is T(*,1)= 293K
the boundary condition is T(1,*)=373k , T(11,*)=T(10,*)
and this is my code
clear
clc
L=10;
n=11;
dx=L/n;
dt=0.005;
t=1;
nt=200;
alpha=0.001;
beta=alpha*dt*(1/(dx)^2);
T0=293;
T1=373;
for j=1:nt
for i=2:n-1
T1(i)=((1-2*beta)*T0(i)+beta*T0(i-1)+beta*T0(i+1));
end
end
plot(T1)
  댓글 수: 1
KSSV
KSSV 2020년 6월 12일
Your T0 is a scalar, and you are using it as a vector.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 6월 12일
T0=293;
That is a scalar.
for i=2:n-1
i starts at 2
T1(i)=((1-2*beta)*T0(i)+beta*T0(i-1)+beta*T0(i+1));
You use T0(i) and T0(i+1) . On the first iteration that would be trying to access T0(2) and T0(2+1) . But T0 is a scalar.
for j=1:nt
Your for i loop does not use j at all, and has no feedback -- the calculation of T1(i) has no reliance on T1(i) calculated from an earlier for j value. Therefore in your code, your for j is a waste of time: every j iteration is going to produce the same T1 vector.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by