필터 지우기
필터 지우기

Solving heat transfer equation using finite difference method

조회 수: 2 (최근 30일)
Michael Omodara
Michael Omodara 2018년 4월 22일
답변: Benjamin Großmann 2018년 4월 23일
Please, I am trying to solve for the temperature distribution in a box but I am having issues with my code error: "Index exceeds matrix dimension". This is my code
M=15.5;
L= 1.22;
dx= 0.122;
T(1)=35;
Tc = 25;
N= L/dx;
St= 50400;
dt= 1800;
rho= 720;
t= St/dt;
T(:,1)=T(1);
K= 0.0676+(0.00054*M);
c= 0.334 +(0.00977*M);
q= 2*10^7;
h= (q*(dx)^2)/K;
for j=1:t
for i=1:N
T(i,j+1)=F(K,dt,dx,rho)*(T(i+1,j)+T(i-1,j)+h)+(1- (2*F(K,dt,dx,rho)))*T(i,j);

답변 (1개)

Benjamin Großmann
Benjamin Großmann 2018년 4월 23일
You start with i=1 and one of your indices is T(i-1), so this is addressing the 0-element of T. In Matlab we start with index 1. This could be one problem but it is not possible to debug your code as it is since there are "end"s missing and the function or Matrix "F" is not given.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by