For loop index exceeds array bounds

Good Afternoon,
I'm having issues finishing my code I am getting an error, I slightly understand what it's asking but I don't have a clue on how to by pass it since my T_inf values are constant for all values of k within that j index.
This is my error
Index in position 2 exceeds array bounds (must not exceed 2).
Error in Project_IIIB (line 86)
Tm_o(i,j,k) = T_inf(i,j) - e(i,j,k) .* (T_inf(i,j) - T_mi);
Anyway to fix it or move around it?
for k = 1 : 20
V(i,j,k) = k + 19;
%inside stuff
Re_Di(i,j,k) = 4 .* mf ./ ( pi .* D(i) .* mu );
NuDi_bar(i,j,k) = 0.023 .* Re_Di(i,j,k) .^ 0.8 .* Pr .^ 0.4 ;
hi_bar(i,j,k) = NuDi_bar(i,j,k) .* k_i ./ D(i) ;
%outside stuff
Re_Do(i,j,k) = V(i,j,k) .* D(i) ./ sp_o(i,j) ;
NuDo_bar(i,j,k) = 0.3 + (0.62 .* Re_Do(i,j,k) .^ (1 ./ 2) .* Pr_o(i,j) .^ (1 ./ 3)) .* (1 + (Re_Do(i,j,k) ./ 282000) .^ (5 ./ 8)) .^ (4 ./ 5) ./ ((1 + (0.4 ./ Pr_o(i,j)) .^ (2 ./ 3)) .^ (1 ./4));
ho_bar(i,j,k) = NuDo_bar(i,j,k) .* k_o(i,j) ./ D(i);
%Finding which one is closest to Tm,o
U_bar(i,j,k) = ((1 ./ hi_bar(i,j,k)) + (1 ./ ho_bar(i,j,k))) .^ (-1);
e(i,j,k) = exp(-((pi .* D(i) .* L) ./ (mf .* cp)) .* U_bar(i,j,k));
Tm_o(i,j,k) = T_inf(i,j) - e(i,j,k) .* (T_inf(i,j) - T_mi);
A = [T_inf(i,j); L(i) ; D(i)];
if (T_mo - 0.1 < Tm_o(i,j,k)) && (T_mo + 0.1 > Tm_o(i,j,k))
T_inf(i,j)
Tm_o(i,j,k)
D(i)
L
end
end

1 个评论

It's a loop indexing issue of the second index which is j in all of the subscripted variables in the code line but--you don't provide any code that shows the loop indices over anything excepting k so we can't know what those indices limits are...
Also, it doesn't show us which was the array it complained about so we don't know even whether it is one of the Txxx or the e array.
What does
whos T* e
show at the command line? That would tell us what dimensions the arrays have, at least, for a starting point.
Or, set a breakpoint on error and look in the debugger to see where you've addressing which array(s) outside their defined bounds.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Matrix Indexing 的更多信息

产品

版本

R2019a

评论:

dpb
2019-6-1

Community Treasure Hunt

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

Start Hunting!

Translated by