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

  1. function s=str2mat(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11)
  2. %STR2MAT Form text matrix from individual strings.
  3. %    S = STR2MAT(T1,T2,T3,..) forms the matrix S containing the text
  4. %    strings T1,T2,T3,... as rows.  Automatically pads each string with
  5. %    spaces in order to form a valid matrix.  Up to 10 text strings 
  6. %    can be used to form S.  Each text parameter, Ti, can itself be a 
  7. %    string matrix.  This allows the creation of arbitarily large
  8. %    string matrices.
  9.  
  10. %    Clay M. Thompson  3-20-91
  11. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  12.  
  13. nstrings = nargin;
  14.  
  15. % Determine the largest string size.
  16. nrows = zeros(1,11); ncols = zeros(1,11);
  17. for i=1:nargin
  18.   sizecall = ['size(t',int2str(i),')'];
  19.   [m,n] = eval(sizecall);
  20.   nrows(i) = max(1,m);
  21.   ncols(i) = n;
  22. end
  23.  
  24. % Now form the string matrix.
  25. s = []; space = ' '; len = max(ncols);
  26. if len == 0,
  27.   t1 = ' ';
  28.   ncols(1) = 1;
  29.   len = 1;
  30. end;
  31.  
  32. for i=1:nargin
  33.   j = int2str(i);  
  34.   formcall = ['[s;[t',j,',space*ones(nrows(',j,'),len-ncols(',j,'))]]'];
  35.   s = eval(formcall);
  36. end
  37.  
  38.