3437
|
1 ## Copyright (C) 1996, 1998 Auburn University. All rights reserved. |
|
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 the |
|
7 ## Free Software Foundation; either version 2, or (at your option) any |
|
8 ## later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## 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 02111 USA. |
|
18 |
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {@var{ioname} =} sysdefioname (@var{n},@var{str} @{,@var{m}@}) |
|
21 ## return default input or output names given @var{n}, @var{str}, @var{m}. |
|
22 ## @var{n} is the final value, @var{str} is the string prefix, and @var{m} |
|
23 ## is start value |
|
24 ## |
|
25 ## used internally, minimal argument checking |
|
26 ## |
|
27 ## @strong{Example} @code{ioname = sysdefioname(5,"u",3)} |
|
28 ## returns the list: |
|
29 ## @example |
|
30 ## ioname = |
|
31 ## ( |
|
32 ## [1] = u_3 |
|
33 ## [2] = u_4 |
|
34 ## [3] = u_5 |
|
35 ## ) |
|
36 ## @end example |
|
37 ## @end deftypefn |
|
38 |
|
39 function ioname = sysdefioname (n, str, m) |
|
40 |
|
41 if (nargin < 2 | nargin > 3) |
|
42 usage("ioname = sysdefioname(n,str[,m])"); |
|
43 endif |
|
44 |
|
45 if (nargin == 2) m = min(1,n); endif |
|
46 |
|
47 ioname = list(); |
|
48 jj = 1; |
|
49 if(n > 0 & m > 0 & m <= n) |
|
50 for ii = m:n |
|
51 ioname(ii+1-m) = sprintf("%s_%d",str,ii); |
|
52 endfor |
|
53 elseif(m > n) |
|
54 error("str=%s; start value m=%d > final value n=%d",str,m,n); |
|
55 endif |
|
56 |
|
57 endfunction |