What is the fprintf size limit?

28 views (last 30 days)
Carl Pray
Carl Pray on 22 Apr 2013
Edited: Jan on 24 Apr 2016
is there a size limit for fprintf? I have a code that writes out large text files with one fprintf command, and if the file gets above about 1 Gb, fprintf will not write it out. The size seems to be about 1E9 characters, but I was interested to know the exact number and could not find that number in any documentation.
  2 Comments
the cyclist
the cyclist on 22 Apr 2013
I see the same behavior [R2013a on Mac running OS X 10.8.3]. The nbytes output is zero, indicating that the command wrote 0 bytes, but there is no error or warning message.
I did a cursory search, and did not find any documentation of this limit.

Sign in to comment.

Accepted Answer

Jan
Jan on 22 Apr 2013
Edited: Jan on 24 Apr 2016
1 GB file size means 1e9 characters, which are 2e9 bytes. This sounds like a 32 bit limit, so please test, if the limit is at 1073741824 characters. If so, the underlying C-function is the cause of the limit.
There have been further limitations of Matlab string functions, when the data contain CHAR(0) in several releases. Even printing a cell string stopped, when one of the elements contained no data, but this has been fixed in R2006a as far as I remember.
  2 Comments
Sergio Grion
Sergio Grion on 11 Sep 2015
I can confirm that this limit still exists in R2015a

Sign in to comment.

More Answers (1)

Richard Laukaitis
Richard Laukaitis on 19 Apr 2016
use fflush to clear the buffer. The buffer size is being limited.

Tags

Community Treasure Hunt

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

Start Hunting!