Mercurial > octave-nkf
comparison scripts/general/num2str.m @ 5947:009fa69b6182
[project @ 2006-08-21 16:15:20 by jwe]
author | jwe |
---|---|
date | Mon, 21 Aug 2006 16:15:20 +0000 |
parents | 2e86e3601e0f |
children | 69e864d21c11 |
comparison
equal
deleted
inserted
replaced
5946:4b433225128d | 5947:009fa69b6182 |
---|---|
30 ## Author: jwe | 30 ## Author: jwe |
31 | 31 |
32 function retval = num2str (x, arg) | 32 function retval = num2str (x, arg) |
33 | 33 |
34 if (nargin != 1 && nargin != 2) | 34 if (nargin != 1 && nargin != 2) |
35 usage ("num2str (x) or num2str (x, precision) or num2str (x, fmt)"); | 35 print_usage (); |
36 endif | 36 endif |
37 | 37 |
38 if (ischar (x)) | 38 if (ischar (x)) |
39 retval = x; | 39 retval = x; |
40 return; | 40 elseif (isempty (x)) |
41 endif | 41 retval = ""; |
42 | 42 elseif (iscomplex (x)) |
43 if (iscomplex (x)) | |
44 if (nargin == 2) | 43 if (nargin == 2) |
45 if (ischar (arg)) | 44 if (ischar (arg)) |
46 fmt = strcat (arg, "%-+", arg(2:end), "i"); | 45 fmt = strcat (arg, "%-+", arg(2:end), "i"); |
47 else | 46 else |
48 if (isnumeric (x) && round (x) == x && abs (x) < (10 .^ arg)) | 47 if (isnumeric (x) && round (x) == x && abs (x) < (10 .^ arg)) |