Index in position 2 exceeds array bounds (must not exceed 6). heat transfer PDE finite difference
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to solve this PDE with finite difference with boundry conditions x=1,T=0 ' x=0,dT/dx=0 ' y=0,dT/dy=0 ' y=1, dT/dy=-T
T_old=ones(7,6);
T_old(:,6)=0;
T_old(1,:)=-T_old(2,:)/2+T_old(3,:);
T_new=zeros(5);
i=1;
if i<5
for j=1:5
T_new(i,j)=9/64+1/8*(T_old(i+1,j)+T_old(i+1,j+2))+3/8*(T_old(i,j+1)+T_old(i+2,j+2));
end
i=i+1;
end
my code gives me this error ''index in position 2 exceeds array bounds (must not exceed 6).''
0 commentaires
Réponses (1)
per isakson
le 16 Déc 2019
The term
T_old(i+1,j+2)
causes the error when j==5, because T_old(2,7) doesn't exist. T_old has only 6 columns.
0 commentaires
Voir également
Catégories
En savoir plus sur Geometry and Mesh dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!