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!