Info
この質問は閉じられています。 編集または回答するには再度開いてください。
problem with for loop
1 回表示 (過去 30 日間)
古いコメントを表示
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
2017 年 12 月 8 日
Learn how to use debugging: https://www.mathworks.com/help/matlab/matlab_prog/debugging-process-and-features.html
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!