Mercurial > hg > octave-nkf
diff scripts/general/int2str.m @ 8442:502e58a0d44f
Fix docstrings, add examples, references and tests to string functions
author | Thorsten Meyer <thorsten.meyier@gmx.de> |
---|---|
date | Mon, 05 Jan 2009 08:11:03 +0100 |
parents | 3422f39573b1 |
children | 2c8b2399247b |
line wrap: on
line diff
--- a/scripts/general/int2str.m +++ b/scripts/general/int2str.m @@ -19,10 +19,31 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} int2str (@var{n}) -## Convert an integer to a string. This function is not very flexible. -## For better control over the results, use @code{sprintf} -## (@pxref{Formatted Output}). -## @seealso{sprintf, num2str} +## Convert an integer (or array of integers) to a string (or a character +## array). +## +## @example +## @group +## +## int2str (123) +## @result{} "123" +## +## s = int2str ([1, 2, 3; 4, 5, 6]) +## @result{} s = +## 1 2 3 +## 4 5 6 +## +## whos s +## @result{} s = +## Attr Name Size Bytes Class +## ==== ==== ==== ===== ===== +## s 2x7 14 char +## @end group +## @end example +## +## This function is not very flexible. For better control over the +## results, use @code{sprintf} (@pxref{Formatted Output}). +## @seealso{sprintf, num2str, mat2str} ## @end deftypefn ## Author: jwe @@ -43,7 +64,7 @@ ifmt = get_fmt (x(idx{:}), 0); idx(2) = 2:sz(2); rfmt = get_fmt (x(idx{:}), 2); - fmt = cstrcat (ifmt, repmat (rfmt, 1, nc-1), "\n") + fmt = cstrcat (ifmt, repmat (rfmt, 1, nc-1), "\n"); else fmt = cstrcat (get_fmt (x, 0), "\n"); endif @@ -93,8 +114,7 @@ endfunction %!assert(strcmp (int2str (-123), "-123") && strcmp (int2str (1.2), "1")); - +%!assert (all (int2str ([1, 2, 3; 4, 5, 6]) == ["1 2 3";"4 5 6"])); %!error int2str (); - %!error int2str (1, 2);