annotate scripts/control/system/__syschnamesl__.m @ 7156:77de8319c337 ss-2-9-17

[project @ 2007-11-10 06:16:59 by jwe]
author jwe
date Sat, 10 Nov 2007 06:17:00 +0000
parents 59dcf01bb3e3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
1 ## Copyright (C) 1996, 2000, 2005, 2007
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
2 ## Auburn University. All rights reserved.
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
3 ##
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
4 ## This file is part of Octave.
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
5 ##
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
7 ## under the terms of the GNU General Public License as published by
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
9 ## your option) any later version.
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
10 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
14 ## General Public License for more details.
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
15 ##
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
16 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
18 ## <http://www.gnu.org/licenses/>.
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
19
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 5443
diff changeset
20 ## Undocumented internal function.
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 5443
diff changeset
21
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
22 ## -*- texinfo -*-
3500
7923abdeb4e5 [project @ 2000-01-31 06:35:00 by jwe]
jwe
parents: 3438
diff changeset
23 ## @deftypefn {Function File} {} __syschnamesl__ (@var{olist}, @var{old_names}, @var{inames}, @var{listname})
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
24 ## used internally in syschnames
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
25 ## item olist: index list
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
26 ## old_names: original list names
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
27 ## inames: new names
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
28 ## listname: name of index list
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
29 ##
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
30 ## combines the two string lists old_names and inames
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
31 ## @end deftypefn
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
32
3438
2e06c3941943 [project @ 2000-01-14 06:33:18 by jwe]
jwe
parents: 3437
diff changeset
33 function old_names = __syschnamesl__ (olist, old_names, inames, listname)
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
34
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
35 probstr = [];
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
36
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
37 if (max (olist) > rows (old_names))
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
38 probstr = sprintf ("index list value(s) exceed(s) number of signals (%d)",
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
39 rows (old_names));
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
40
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
41 elseif (length (olist) > rows (inames))
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
42 probstr = sprintf ("index list dimension exceeds number of replacement names (%d)",
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
43 rows (inames));
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
44
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
45 elseif (isempty (olist))
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
46 probstr = []; # do nothing, no changes
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
47
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
48 elseif (min (size (olist)) != 1)
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
49 probstr = "index list must be either a vector or an empty matrix";
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
50
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
51 elseif (max (olist) > rows (old_names))
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
52 probstr = sprintf ("max(%s)=%d > %d, too big", listname,
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
53 max (olist), rows (old_names));
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
54
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
55 elseif (min (olist) < 1)
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
56 probstr = sprintf ("min(%s)=%d < 1, too small", listname, min (olist));
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
57
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
58 else
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
59 if (length(olist) == 1)
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
60 len_in = columns (inames);
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
61 len_out = columns (old_names);
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
62
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
63 if (len_in < len_out)
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
64 inames(1,(len_in+1):(len_out)) = zeros (1, len_out-len_in);
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
65 endif
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
66
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
67 old_names(olist,1:length(inames)) = inames;
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
68 elseif (length(olist) > 1)
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
69 for ii = 1:length(olist)
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
70 mystr = inames(ii,:);
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
71 len_my = columns (mystr);
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
72 len_out = columns (old_names);
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
73
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
74 if (len_my < len_out)
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
75 mystr(1,(len_my+1):len_out) = repmat (" ", 1, len_out-len_my);
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
76 len_my = len_out;
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
77 endif
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
78
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
79 old_names(olist(ii),1:len_my) = mystr;
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
80 endfor
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
81 endif
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
82 endif
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
83 if (! isempty (probstr))
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
84 ## the following lines are NOT debugging code!
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
85 disp ("Problem in syschnames: old names are")
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
86 __outlist__ (old_names," ")
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
87 disp ("new names are")
3438
2e06c3941943 [project @ 2000-01-14 06:33:18 by jwe]
jwe
parents: 3437
diff changeset
88 __outlist__(inames," ")
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
89 disp ("list indices are")
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
90 disp (olist)
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
91 error (sprintf ("syschnames: \"%s\" dim=(%d x %d)--\n\t%s\n", ...
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
92 listname, rows (olist), columns (olist), probstr));
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
93 endif
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
94
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
95 ## change zeros to blanks
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
96 if (find (old_names == 0))
3438
2e06c3941943 [project @ 2000-01-14 06:33:18 by jwe]
jwe
parents: 3437
diff changeset
97 ## disp("__syschnamesl__: old_names contains zeros ")
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
98 ## old_names
3438
2e06c3941943 [project @ 2000-01-14 06:33:18 by jwe]
jwe
parents: 3437
diff changeset
99 ## disp("/__syschnamesl__");
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
100
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
101 [ii, jj] = find (old_names == 0);
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
102 for idx = 1:length(ii)
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
103 old_names(ii(idx),jj(idx)) = " ";
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
104 endfor
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
105
3438
2e06c3941943 [project @ 2000-01-14 06:33:18 by jwe]
jwe
parents: 3437
diff changeset
106 ## disp("__syschnamesl__: old_names fixed zeros ")
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
107 ## old_names
3438
2e06c3941943 [project @ 2000-01-14 06:33:18 by jwe]
jwe
parents: 3437
diff changeset
108 ## disp("/__syschnamesl__");
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
109 endif
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
110
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
111 ## just in case it's not a string anymore
7136
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
112 if (! ischar (old_names))
59dcf01bb3e3 [project @ 2007-11-08 20:18:25 by jwe]
jwe
parents: 7017
diff changeset
113 old_names = char (old_names);
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
114 endif
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
115
3438
2e06c3941943 [project @ 2000-01-14 06:33:18 by jwe]
jwe
parents: 3437
diff changeset
116 ## disp("__syschnamesl__: exit, old_names=")
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
117 ## old_names
3438
2e06c3941943 [project @ 2000-01-14 06:33:18 by jwe]
jwe
parents: 3437
diff changeset
118 ## disp("/__syschnamesl__: exiting")
3437
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
119
3c609681b2bf [project @ 2000-01-14 06:00:00 by jwe]
jwe
parents:
diff changeset
120 endfunction