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

질문:

2019년 6월 1일

댓글:

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