[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## showing progress of a for loop in a function

**From**: |
novakyu |

**Subject**: |
showing progress of a for loop in a function |

**Date**: |
Tue, 13 Nov 2007 15:42:09 -0800 |

Hi,
I have a function that executes a fairly time-consuming for loop, and
I would like to track progress of the loop, so that I know whether to
interrupt the function call or not
I tried "disp(j)" and "fdisp(j)" (where j is the index I'm looping
over), but it looks like octave does not print the output until the
whole function finishes.
Is there any other way to track how many loops it's gone through?
Regards,
Andrzej
P.S. The function looks something like:
===
function [y1 y2] = NSolve(f, t, y1_0, y2_0)
y1 = zeros(size(t));
y2 = zeros(size(t));
y1(1) = y1_0;
y2(1) = y2_0;
for j = linspace(1,length(t)-1,length(t)-1)
y1(j + 1) = y1(j) + (t(j + 1) - t(j))*f(t)*y2(j)
y2(j + 1) = y2(j) + (t(j + 1) - t(j))*f(t)*y1(j)
endfor
endfunction
===
And for precision issues, I need something around a million iterations
of the for loop.

**showing progress of a for loop in a function**,
*novakyu* **<=**