Index in position 2 exceeds array bounds (must not exceed 1)
3 ビュー (過去 30 日間)
古いコメントを表示
I am solving a I D transient heat conduction equation (given below) and I keep getting this error, I am unable to resolve it.
ANY HELP IS APPRECIATED
u_c = zeros(n+1,1);
u_p = zeros(n+1,1);
for i = 1:n+1
u_c(i+1,1) = U_i;
end
for m = 2:T+1 % Time Loop
for i = 2:n % Space Loop
u_c(m,i+1) = u_p(m,i+1) + 0.5*(u_p(m+1,i+1)-(2*u_p(m,i+1))+u_p(m-1,i+1)) ;
end
u_p = u_c;
u_c(1,i) = ((k*u_p(1,i)) + (dx*h*U_f))/(k+(dx*h));
u_c(n,i) = ((k-(dx*h))*u_p(n-1,i))+(U_f*dx)/k;
end
0 件のコメント
回答 (1 件)
meghannmarie
2019 年 9 月 30 日
編集済み: meghannmarie
2019 年 9 月 30 日
The variables u_c and u_p are vectors or the size of the second dimension is 1. Then you try to set these variables with i in the second dimension which is more than 1. Maybe first 2 lines should be this:
u_c = zeros(n+1,T+2);
u_p = zeros(n+1,T+2);
Hard to tell without the data.
参考
カテゴリ
Help Center および File Exchange で Mathematics and Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!