Mercurial > octave-nkf
comparison scripts/control/system/syssetsignals.m @ 4771:b8105302cfe8
[project @ 2004-02-16 17:45:50 by jwe]
author | jwe |
---|---|
date | Mon, 16 Feb 2004 17:45:50 +0000 |
parents | 22bd65326ec1 |
children | bdbee5282954 |
comparison
equal
deleted
inserted
replaced
4770:ef5e598f099b | 4771:b8105302cfe8 |
---|---|
49 ## @end table | 49 ## @end table |
50 ## @item sig_idx | 50 ## @item sig_idx |
51 ## indices or names of outputs, yd, inputs, or | 51 ## indices or names of outputs, yd, inputs, or |
52 ## states whose respective names/values should be changed. | 52 ## states whose respective names/values should be changed. |
53 ## | 53 ## |
54 ## Default: replace entire list of names/entire yd vector. | 54 ## Default: replace entire cell array of names/entire yd vector. |
55 ## @end table | 55 ## @end table |
56 ## @strong{Outputs} | 56 ## @strong{Outputs} |
57 ## @var{retsys=sys} with appropriate signal names changed | 57 ## @var{retsys=sys} with appropriate signal names changed |
58 ## (or yd values, where appropriate) | 58 ## (or yd values, where appropriate) |
59 ## | 59 ## |
60 ## @strong{Example} | 60 ## @strong{Example} |
61 ## @example | 61 ## @example |
62 ## octave:1> sys=ss2sys([1 2; 3 4],[5;6],[7 8]); | 62 ## octave:1> sys=ss([1 2; 3 4],[5;6],[7 8]); |
63 ## octave:2> sys = syssetsignals(sys,"st",str2mat("Posx","Velx")); | 63 ## octave:2> sys = syssetsignals(sys,"st",str2mat("Posx","Velx")); |
64 ## octave:3> sysout(sys) | 64 ## octave:3> sysout(sys) |
65 ## Input(s) | 65 ## Input(s) |
66 ## 1: u_1 | 66 ## 1: u_1 |
67 ## Output(s): | 67 ## Output(s): |
119 endif | 119 endif |
120 | 120 |
121 sig_vals = sysgetsignals(sys,opt); | 121 sig_vals = sysgetsignals(sys,opt); |
122 | 122 |
123 ## make sure it's in state space form if state names are given | 123 ## make sure it's in state space form if state names are given |
124 if(strcmp(opt,"st")) sys = sysupdate(sys,"ss"); endif | 124 if(strcmp(opt,"st")) |
125 sys = sysupdate(sys,"ss"); | |
126 endif | |
125 | 127 |
126 if(strcmp(opt,"yd") == 0) | 128 if(strcmp(opt,"yd") == 0) |
127 ## it's a signal name list we're changing | 129 ## it's a signal name list we're changing |
128 if(!islist(names)) | 130 if(!iscell(names)) |
129 names = list(names); | 131 names = {names}; |
130 endif | 132 endif |
131 if(!is_signal_list(names)) | 133 if( (!is_signal_list(names)) & (!isempty(names)) ) |
132 if(isstr(nth(names,1))) | 134 if(isstr(names{1})) |
133 warning("syssetsignals(opt=%s): converting string matrix \"names\" to a list of strings",opt); | 135 warning("syssetsignals(opt=%s): converting string matrix \"names\" to a cell array of strings",opt); |
134 tmpstr = nth(names,1); | 136 tmpstr = names{1}; |
135 for ii=1:rows(tmpstr) | 137 for ii=1:rows(tmpstr) |
136 names(ii) = deblank(tmpstr(ii,:)); | 138 names{ii} = deblank(tmpstr(ii,:)); |
137 endfor | 139 endfor |
138 else | 140 else |
139 names | 141 names |
140 error("parameter \"names\" must be a list of strings"); | 142 error("parameter \"names\" must be a cell array of strings"); |
141 endif | 143 endif |
142 endif | 144 endif |
143 nsigs = length(sig_vals); | 145 nsigs = length(sig_vals); |
144 | 146 |
145 if(nargin == 3) | 147 if(nargin == 3) |
159 jj = sig_idx(ii); | 161 jj = sig_idx(ii); |
160 if(jj < 1 | jj > nsigs | jj != floor(jj+0.5)) | 162 if(jj < 1 | jj > nsigs | jj != floor(jj+0.5)) |
161 error("opt=%s, sig_idx(%d)=%d, %e: must be an integer between 1 and %d", ... | 163 error("opt=%s, sig_idx(%d)=%d, %e: must be an integer between 1 and %d", ... |
162 opt, ii, jj, jj, nsigs); | 164 opt, ii, jj, jj, nsigs); |
163 endif | 165 endif |
164 sig_vals(jj) = nth(names,ii); | 166 sig_vals{jj} = names{ii}; |
165 endfor | 167 endfor |
166 | 168 |
167 else | 169 else |
168 ## update yd | 170 ## update yd |
169 ## 1st check pathological case: no outputs | 171 ## 1st check pathological case: no outputs |