[SOLVED] Print inside loop

View: New views
7 Messages — Rating Filter:   Alert me  

[SOLVED] Print inside loop

by RicardoCaruso () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If I put printf() in a for loop, the message doesn't appear until the loop is finished. Is there any way to output a string before that?

Re: Print inside loop

by Judd Storrs :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It would be helpful if you could provide an example of the problem.
I'll try and guess that you need to include

more off

sometime prior to your loop to disable the pager.


--judd


On Wed, Oct 28, 2009 at 11:02 PM, RicardoCaruso
<lorenzorodrigo2000@...> wrote:

>
> If I put printf() in a for loop, the message doesn't appear until the loop is
> finished. Is there any way to output a string before that?
> --
> View this message in context: http://www.nabble.com/Print-inside-loop-tp26105461p26105461.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> Help-octave@...
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave

Re: Print inside loop

by RicardoCaruso :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for answering.
I have something like this:

for j=1:N

        printf("Iteration %d", j); %All of this strings appear when the function finish.

        % ... some operations that take quite a long time...
 
end

I don't want all the strings to be printed at the end.

Judd Storrs wrote:
It would be helpful if you could provide an example of the problem.
I'll try and guess that you need to include

more off

sometime prior to your loop to disable the pager.


--judd


On Wed, Oct 28, 2009 at 11:02 PM, RicardoCaruso
<lorenzorodrigo2000@hotmail.com> wrote:
>
> If I put printf() in a for loop, the message doesn't appear until the loop is
> finished. Is there any way to output a string before that?
> --
> View this message in context: http://www.nabble.com/Print-inside-loop-tp26105461p26105461.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> Help-octave@octave.org
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>
_______________________________________________
Help-octave mailing list
Help-octave@octave.org
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave

Re: Print inside loop

by Carlo de Falco-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 29 Oct 2009, at 07:11, RicardoCaruso wrote:

>
> Thanks for answering.
> I have something like this:
>
> for j=1:N
>
>        printf("Iteration %d", j); %All of this strings appear when the
> function finish.
>
> % ... some operations that take quite a long time...
>
> end
>
> I don't want all the strings to be printed at the end.

have you disabled the pager before running your code?
try typing the command

more off

at the beginning of your Octave session
c.
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave

Re: Print inside loop

by RicardoCaruso :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, that worked great!
I didn't know that command.
Thanks!

Carlo de Falco-2 wrote:
On 29 Oct 2009, at 07:11, RicardoCaruso wrote:

>
> Thanks for answering.
> I have something like this:
>
> for j=1:N
>
>        printf("Iteration %d", j); %All of this strings appear when the
> function finish.
>
> % ... some operations that take quite a long time...
>
> end
>
> I don't want all the strings to be printed at the end.

have you disabled the pager before running your code?
try typing the command

more off

at the beginning of your Octave session
c.
_______________________________________________
Help-octave mailing list
Help-octave@octave.org
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave

Re: Print inside loop

by Tatsuro MATSUOKA-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Please try

page_screen_output (false)
for i=1:10; disp(i);pause(1);end

However this disable pager.
If you would like to keep pager active,

Please try
for i=1:10; fprintf(stderr, "%d\n",i);pause(1);end

without

page_screen_output (false)

Good luck!

Tatsuro
--- RicardoCaruso wrote:

>
> If I put printf() in a for loop, the message doesn't appear until the loop is
> finished. Is there any way to output a string before that?
> --
> View this message in context: http://www.nabble.com/Print-inside-loop-tp26105461p26105461.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> Help-octave@...
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>


--------------------------------------
GyaO! - Anime, Dramas, Movies, and Music videos [FREE]
http://pr.mail.yahoo.co.jp/gyao/
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave

Parent Message unknown Re: Print inside loop

by Chengqi Chang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> If I put printf() in a for loop, the message doesn't appear until the  
> loop is
> finished. Is there any way to output a string before that?
> --View this message in context:  
> http://www.nabble.com/Print-inside-loop-tp26105461p26105461.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
for i=1:10; fprintf(stderr, "%d\n",i);fflush(1);end

--
Best Regards!
---------------------------
Sincerely Yours             Chengqi Chang
China Center for Economic Research
Mail: XaeroChina@...
Personal Website: http://macro2.cn
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave