Mercurial > octave-nkf
comparison scripts/general/int2str.m @ 11469:c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 09 Jan 2011 12:41:21 -0800 |
parents | 95c3e38098bf |
children | fd0a3ac60b0e |
comparison
equal
deleted
inserted
replaced
11468:e1edf0ba3bcb | 11469:c776f063fefe |
---|---|
46 ## @seealso{sprintf, num2str, mat2str} | 46 ## @seealso{sprintf, num2str, mat2str} |
47 ## @end deftypefn | 47 ## @end deftypefn |
48 | 48 |
49 ## Author: jwe | 49 ## Author: jwe |
50 | 50 |
51 function retval = int2str (x) | 51 function retval = int2str (n) |
52 | 52 |
53 if (nargin == 1) | 53 if (nargin == 1) |
54 x = round (real(x)); | 54 n = round (real(n)); |
55 sz = size(x); | 55 sz = size(n); |
56 nd = ndims (x); | 56 nd = ndims (n); |
57 nc = columns (x); | 57 nc = columns (n); |
58 if (nc > 1) | 58 if (nc > 1) |
59 idx = cell (); | 59 idx = cell (); |
60 for i = 1:nd | 60 for i = 1:nd |
61 idx{i} = 1:sz(i); | 61 idx{i} = 1:sz(i); |
62 endfor | 62 endfor |
63 idx(2) = 1; | 63 idx(2) = 1; |
64 ifmt = get_fmt (x(idx{:}), 0); | 64 ifmt = get_fmt (n(idx{:}), 0); |
65 idx(2) = 2:sz(2); | 65 idx(2) = 2:sz(2); |
66 rfmt = get_fmt (x(idx{:}), 2); | 66 rfmt = get_fmt (n(idx{:}), 2); |
67 fmt = cstrcat (ifmt, repmat (rfmt, 1, nc-1), "\n"); | 67 fmt = cstrcat (ifmt, repmat (rfmt, 1, nc-1), "\n"); |
68 else | 68 else |
69 fmt = cstrcat (get_fmt (x, 0), "\n"); | 69 fmt = cstrcat (get_fmt (n, 0), "\n"); |
70 endif | 70 endif |
71 tmp = sprintf (fmt, permute (x, [2, 1, 3 : nd])); | 71 tmp = sprintf (fmt, permute (n, [2, 1, 3 : nd])); |
72 tmp(end) = ""; | 72 tmp(end) = ""; |
73 retval = char (strsplit (tmp, "\n")); | 73 retval = char (strsplit (tmp, "\n")); |
74 else | 74 else |
75 print_usage (); | 75 print_usage (); |
76 endif | 76 endif |