File: fprintfBug.m

package info (click to toggle)
psychtoolbox-3 3.0.14.20170103%2Bgit6-g605ff5c.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,044 kB
  • ctags: 69,483
  • sloc: ansic: 167,371; cpp: 11,232; objc: 4,708; sh: 1,875; python: 383; php: 344; makefile: 207; java: 113
file content (49 lines) | stat: -rw-r--r-- 1,506 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function fprintfBug
% Mathworks Case ID:  201530, reported 3/19/99
% 
% FPRINTF may interpret the first argument as a filename.
% 
% Dear Denis,
% 
% I am responding to your e-mails of March 19, concerning FPRINTF.
% 
% > in my first message (below) i noted that
% >
% > >fprintf('"%s" hit at time %.3f s\n','5%',1)
% > >
% > >produces no output at all.
% >
% > I now discover that FPRINTF created a file called '"%s" hit
% > at time %.3f s\n' on my disk, and stored a '5' in it each
% > time i executed that statement. Treating the first argument
% > of FPRINTF as a file NAME is undocumented, and not what I
% > expected.
% >
% > Can you clarify what Matlab is doing?
% 
% Yes, this behavior is due to a bug in the FPRINTF command.  For some
% reason, passing more than two arguments to FPRINTF can cause the first
% argument to be treated as the filename or file ID.  This has been reported
% to our development staff to be addressed in a future version of Matlab.
% 
% As a workaround you can manually specify FID to 1 (for standard output) in
% your FPRINTF statement:
% 
%   a='%04d';
%   fprintf(1,'ls %s %i\n',a,4);
% 
% Another workaround is to make multiple calls to the FPRINTF command.  For
% example:
% 
%   a='%04d';
%   fprintf('ls %s ',a);
%   fprintf('%d\n',4);
% 
% If you have further questions regarding this issue, please be sure to
% mention the above case ID number in your e-mail response to me.
% 
% Sincerely,
% 
% Jeff Mather
% Technical Support Engineer
% jmather@mathworks.com