Info

この質問は閉じられています。 編集または回答するには再度開いてください。

problem with for loop

1 回表示 (過去 30 日間)
alireza amiri
alireza amiri 2017 年 12 月 8 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi I have problem with for loop ; when i run this code,i think probably one loop does not stop and matlab stays on busy mode i want to understand where is the problem in my program (i attached all functions to this question)
a part of code:
for i=2:length(x)-1
for j=2:length(y)-1
z = 0:0.1:1;
for zindex=1:11
for nindex = [1,10]
u(i, j, 2, zindex+1, nindex)= G(z(zindex), nindex)/ro(z(zindex), nindex)^2*dt^2*((1/deltar^2)*(u(i+1,j,1)-2*u(i,j,1)+u(i-1,j,1))...
+(1/(ri*2*deltar))*(u(i+1,j,1)-u(i-1,j,1))+(1/deltaz^2)*(u(i,j+1,1)-2*u(i,j,1)+u(i,j-1,1))-(1/ri^2)*(u(i,j,1))) + 2*u(i,j,1) - u(i,j,1);
end
end
end
end
for n=2:length(t)-1
for i=2:length(x)-1
for j=2:length(y)-1
z = 0:0.1:1;
for zindex=1:11
for nindex = [1,10]
u(i,j,n+1,zindex+1,nindex)= G(z(zindex), nindex)/ro(z(zindex), nindex)^2*dt^2*((1/deltar^2)*(u(i+1,j,n)-2*u(i,j,n)+u(i-1,j,n))...
+(1/(ri*2*deltar))*(u(i+1,j,n)-u(i-1,j,n))+(1/deltaz^2)*(u(i,j+1,n)-2*u(i,j,n)+u(i,j-1,n))-(1/ri^2)*(u(i,j,n))) + 2*u(i,j,n) - u(i,j,n-1);
end
end
end
end
end
  2 件のコメント
KL
KL 2017 年 12 月 8 日
KSSV
KSSV 2017 年 12 月 8 日
Try to take loop indices as output's on the screen.....and check at what indices it is taking much time...or run a profiler for small indices.

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by