6138
|
1 ## Copyright (C) 1996, 2006 Kurt Hornik |
2325
|
2 ## |
2313
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
2313
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
2268
|
18 |
3361
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} blanks (@var{n}) |
|
21 ## Return a string of @var{n} blanks. |
6138
|
22 ## @seealso{repmat} |
3361
|
23 ## @end deftypefn |
2311
|
24 |
5428
|
25 ## Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> |
2355
|
26 ## Adapted-By: jwe |
2314
|
27 |
2268
|
28 function s = blanks (n) |
2325
|
29 |
2268
|
30 if (nargin != 1) |
6046
|
31 print_usage (); |
6138
|
32 elseif (! (isscalar (n) && n == round (n))) |
3081
|
33 error ("blanks: n must be a non-negative integer"); |
2268
|
34 endif |
2325
|
35 |
6387
|
36 ## If 1:n is empty, the following expression will create an empty |
|
37 ## character string. Otherwise, it will create a row vector. |
|
38 s(1:n) = " "; |
6138
|
39 |
2268
|
40 endfunction |
6138
|
41 |
|
42 ## There really isn't that much to test here |
|
43 %!assert(blanks (0), "") |
|
44 %!assert(blanks (5), " ") |
|
45 %!assert(blanks (10), " ") |