home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / IOFUN.DI$ / FPRINTF.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  2.4 KB  |  59 lines

  1. %FPRINTF Write formatted data to file.
  2. %    COUNT = FPRINTF(FID,FORMAT,A,...) formats the data in matrix A (and in
  3. %    any additional matrix arguments), under control of the specified FORMAT
  4. %    string, and writes it to the file associated with file identifier FID.
  5. %    COUNT is an optional output argument that returns the number of bytes
  6. %    successfully written.
  7. %
  8. %    FID is an integer file identifier obtained from FOPEN. It can also
  9. %    be 1 for standard output (the screen) or 2 for standard error.
  10. %    
  11. %    FORMAT is a string containing C language conversion specifications.
  12. %    Conversion specifications involve the character %, optional flags,
  13. %    optional width and precision fields, optional subtype specifier, and
  14. %    conversion characters d, i, o, u, x, X, f, e, E, g, G, c, and s.
  15. %    See a C manual for complete details.
  16. %
  17. %    FPRINTF behaves like ANSI C with certain exceptions and extensions. 
  18. %    These include:
  19. %
  20. %    1. If the MATLAB double doesn't convert exactly to the datatype
  21. %       associated with the conversion specifier then e format is used.
  22. %       You must explicitly convert non-integral MATLAB values to
  23. %       integral values if you plan to use an integral conversion
  24. %       specifier like d and get the expected ANSI C behavior.
  25. %    2. The following non-standard subtype specifiers are supported for
  26. %       conversion characters o, u, x, and X.
  27. %
  28. %       t    - The underlying C datatype is a float rather than an
  29. %          unsigned integer.
  30. %       b    - The underlying C datatype is a double rather than an
  31. %          unsigned integer.
  32. %
  33. %       For example, to print out in hex a double value use a format like
  34. %       '%bx'.
  35. %
  36. %    FPRINTF also differs from its C language namesake in an important
  37. %    respect - it is "vectorized" for the case when A is nonscalar. The
  38. %    format string is recycled through the elements of A (columnwise) until
  39. %    all the elements are used up. It is then recycled in a similar manner, 
  40. %    without reinitializing, through any additional matrix arguments.
  41. %    
  42. %    For example, the statements
  43. %
  44. %        x = 0:.1:1; y = [x; exp(x)];
  45. %        fid = fopen('exp.txt','w');
  46. %        fprintf(fid,'%6.2f  %12.8f\n',y);
  47. %
  48. %    create a text file containing a short table of the exponential function:
  49. %
  50. %        0.00    1.00000000
  51. %        0.10    1.10517092
  52. %             ...
  53. %        1.00    2.71828183
  54. %
  55. %    See also FSCANF, SPRINTF, FWRITE, DIARY, SAVE.
  56.  
  57. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  58. %    Built-in function.
  59.