comparison scripts/general/repmat.m @ 3914:9eb96199e0f1

[project @ 2002-04-30 02:40:04 by jwe]
author jwe
date Tue, 30 Apr 2002 02:40:04 +0000
parents
children 2f341412622f
comparison
equal deleted inserted replaced
3913:f11cfbfc84b5 3914:9eb96199e0f1
1 ## Copyright (C) 2000 Paul Kienzle
2 ##
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
7 ## the Free Software Foundation; either version 2, or (at your option)
8 ## any later version.
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
16 ## along with Octave; see the file COPYING. If not, write to the Free
17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
18 ## 02111-1307, USA.
19
20 ## -*- texinfo -*-
21 ## @deftypefn {Function File} {} repmat (@var{A}, @var{m}, @var{n})
22 ## @deftypefnx {Function File} {} repmat (@var{A}, [@var{m} @var{n}])
23 ## Form a block matrix of size @var{m} by @var{n}, with a copy of matrix
24 ## @var{A} as each element. If @var{n} is not specified, form an
25 ## @var{m} by @var{m} block matrix.
26 ## @end deftypefn
27
28 ## Author: Paul Kienzle <pkienzle@kienzle.powernet.co.uk>
29 ## Created: July 2000
30
31 function x = repmat (b, m, n)
32 if (nargin < 2 || nargin > 3)
33 usage ("repmat (a, m, n)");
34 endif
35
36 if (nargin == 2)
37 if (is_scalar (m))
38 n = m;
39 elseif (is_vector (m) && length (m) == 2)
40 n = m(2);
41 m = m(1);
42 else
43 error ("repmat: only builds 2D matrices")
44 endif
45 endif
46
47 if (isstr (a))
48 x = setstr (kron (ones (m, n), toascii (a)));
49 else
50 x = kron (ones (m, n), a);
51 endif
52
53 endfunction