Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
problem with for loop
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
KL
le 8 Déc 2017
Learn how to use debugging: https://www.mathworks.com/help/matlab/matlab_prog/debugging-process-and-features.html
KSSV
le 8 Déc 2017
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.
Réponses (0)
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!