Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
flush output from fprintf

Subject: flush output from fprintf

From: David Epstein

Date: 16 Jun, 2012 06:59:08

Message: 1 of 2

I'm trying to understand how a very long program is operating, so I put some fprintf statements into the code. However the program seems to get far ahead before releasing the fprintf output, which seems to have been stored in some buffer.

Is it possible to flush the output of fprintf so that it emerges immediately? Like the drawnow command would do for graphics output.

Thanks
David

Subject: flush output from fprintf

From: Nasser M. Abbasi

Date: 16 Jun, 2012 07:14:30

Message: 2 of 2

On 6/16/2012 1:59 AM, David Epstein wrote:
> I'm trying to understand how a very long program is operating, so I put some
>fprintf statements into the code. However the program seems to get far ahead
>before releasing the fprintf output, which seems to have been stored in some buffer.

Not according to

http://blogs.mathworks.com/loren/2006/04/19/high-performance-file-io/

"The default behavior for fprintf and fwrite is to flush the
file buffer after each call to either of these functions."

See above article for more info. For example, if do this

help fopen

>>
  'W' open file for writing without automatic flushing
>>

then you wont get automatic flushing.

--Nasser

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us