help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: showing progress of a for loop in a function


From: Joshua Rigler
Subject: Re: showing progress of a for loop in a function
Date: Tue, 13 Nov 2007 17:05:09 -0700
User-agent: Thunderbird 1.5.0.12 (X11/20070530)

Woohoo!  The one question I have an answer for:

Turn off pagination ("more off"), or force Octave to display all output immediately ("page_output_immediately(1)"). You might also try placing "fflush(stdout)" after "disp(j)" in your code, but that's probably more trouble than it's worth. Keep in mind, only the first solution works in the other leading product, if compatibility is an issue.

Also, this question has been answered quite often on the list. You should check out the search engine at:

  http://www.nabble.com/Octave-f1895.html

-EJR


novakyu wrote:
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.
_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave


reply via email to

[Prev in Thread] Current Thread [Next in Thread]