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

  1. %SSCANF    Read string under format control.
  2. %    [A,COUNT,ERRMSG,NEXTINDEX] = SSCANF(S,FORMAT,SIZE) reads data from
  3. %    MATLAB string variable S, converts it according to the specified
  4. %    FORMAT string, and returns it in matrix A. COUNT is an optional output
  5. %    argument that returns the number of elements successfully read.
  6. %       ERRMSG is an optional output argument that returns an error message
  7. %    string if an error occurred or an empty matrix if an error did not
  8. %    occur. NEXTINDEX is an optional output argument specifyiny one more
  9. %    than the number of characters scanned in S.
  10. %
  11. %    SSCANF is the same as FSCANF except that it reads the data from
  12. %    a MATLAB string variable rather than reading it from a file.
  13. %    
  14. %    SIZE is optional; it puts a limit on the number of elements that
  15. %    can be scanned from the string; if not specified, the entire string
  16. %    is considered; if specified, valid entires are: 
  17. %        N      read at most N elements into a column vector.
  18. %        inf    read at most to the end of the string.
  19. %        [M,N]  read at most M * N elements filling at least an
  20. %               M-by-N matrix, in column order. N can be inf, but not M.
  21. %    
  22. %       FORMAT is a string containing C language conversion specifications.
  23. %       Conversion specifications involve the character %, optional
  24. %       assignment-suppressing asterisk and width field, and conversion
  25. %       characters d, i, o, u, x, e, f, g, s, c, and [. . .] (scanset).
  26. %       Complete ANSI C support for these conversion characters is
  27. %       provided consistent with 'expected' MATLAB behavior. For a complete
  28. %       conversion character specification, see a C manual.
  29. %
  30. %       If a conversion character s is used, an element read may cause
  31. %       several MATLAB matrix elements to be used, each holding one
  32. %       character.
  33. %
  34. %    Mixing character and numeric conversion specifications will cause
  35. %    the resulting matrix to be numeric and any characters read to show
  36. %    up as their ASCII values one character per MATLAB matrix element.
  37. %
  38. %    Scanning to end-of-string occurs when NEXTINDEX is greater than the
  39. %    size of S.
  40. %
  41. %    SSCANF differs from its C language namesake in an important respect -
  42. %    it is "vectorized" in order to return a matrix argument. The format
  43. %    string is recycled through the the string until its end is reached
  44. %    or the amount of data specified by SIZE is converted in.
  45. %
  46. %    For example, the statements
  47. %
  48. %        S = '2.7183  3.1416';
  49. %        A = sscanf(S,'%f')
  50. %
  51. %    create a two element vector containing approximations to e and pi.
  52. %
  53. %    See also FSCANF, SPRINTF, FREAD.
  54.  
  55. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  56. %    Built-in function.
  57.