Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

problem with for loop

1 visualizzazione (ultimi 30 giorni)
alireza amiri
alireza amiri il 8 Dic 2017
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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 Commenti
KSSV
KSSV il 8 Dic 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.

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by