Mercurial > hg > octave-terminal
changeset 3455:f758be6e1730
[project @ 2000-01-18 19:57:12 by hodelas]
frequency response and sysprune functions allow input of signal names or
signal indices.
author | hodelas |
---|---|
date | Tue, 18 Jan 2000 19:57:13 +0000 |
parents | d8b731d3f7a3 |
children | 434790acb067 |
files | scripts/control/base/__bodquist__.m scripts/control/base/bode.m scripts/control/base/nichols.m scripts/control/base/nyquist.m scripts/control/system/sysprune.m |
diffstat | 5 files changed, 49 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/control/base/__bodquist__.m +++ b/scripts/control/base/__bodquist__.m @@ -17,7 +17,7 @@ ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{f}, @var{w}] =} __bodquist__ (@var{sys}, @var{w}, @var{out_idx}, @var{in_idx}) +## @deftypefn {Function File} {[@var{f}, @var{w}, @var{rsys} =} __bodquist__ (@var{sys}, @var{w}, @var{out_idx}, @var{in_idx}) ## used internally by bode, nyquist; compute system frequency response. ## ## @strong{Inputs} @@ -27,11 +27,11 @@ ## @item w ## range of frequencies; empty if user wants default ## @item out_idx -## list of outputs; empty if user wants all +## vector output indices or list of output signal names; empty if user wants all ## @item in_idx -## list of inputs; empty if user wants all +## vector of input indices of list of input signal names; empty if user wants all ## @item rname -## name of routine that called __bodquist__ ("bode" or "nyquist") +## name of routine that called __bodquist__ ("bode", "nyquist", or "nichols") ## @end table ## @strong{Outputs} ## @table @var @@ -39,18 +39,19 @@ ## list of frequencies ## @item f ## frequency response of sys; @math{f(ii) = f(omega(ii))} +## @item rsys +## system with selected inputs and outputs ## @end table -## @strong{Note} __bodquist__ could easily be incorporated into a Nichols -## plot function; this is in a "to do" list. ## -## Both bode and nyquist share the same introduction, so the common parts are +## @code{bode}, @code{nichols}, and @code{nyquist} share the same +## introduction, so the common parts are ## in __bodquist__. It contains the part that finds the number of arguments, ## determines whether or not the system is SISO, and computes the frequency ## response. Only the way the response is plotted is different between the -## two functions. +## these functions. ## @end deftypefn -function [f, w] = __bodquist__ (sys, w, outputs, inputs, rname) +function [f, w, rsys] = __bodquist__ (sys, w, outputs, inputs, rname) ## check number of input arguments given if (nargin != 5) @@ -73,7 +74,12 @@ if (isempty(inputs)) inputs = 1:mm; # use all inputs warning([rname,": outputs specified but not inputs"]); + elseif(is_signal_list(inputs) | isstr(inputs)) + inputs = sysidx(sys,"in",inputs); endif + if(is_signal_list(outputs) | isstr(outputs)) + outputs = sysidx(sys,"out",outputs); + end sys = sysprune(sys,outputs,inputs); [nn,nz,mm,pp ] = sysdimensions(sys); endif @@ -154,4 +160,7 @@ w = w(w_idx); f = f(w_idx); + ## set rsys to pruned system + rsys = sys; + endfunction
--- a/scripts/control/base/bode.m +++ b/scripts/control/base/bode.m @@ -1,4 +1,4 @@ -## Copyright (C) 1996, 1998 Auburn University. All rights reserved. +## Copyright (C) 1996, 1998, 2000 Auburn University. All rights reserved. ## ## This file is part of Octave. ## @@ -61,8 +61,13 @@ ## @end enumerate ## @item out_idx ## @itemx in_idx -## the indices of the output(s) and input(s) to be used in -## the frequency response; see @code{sysprune}. +## +## The names or indices of outputs and inputs to be used in the frequency +## response. See @code{sysprune}. +## +## @example +## bode(sys,[],"y_3",list("u_1","u_4"); +## @end example ## @end table ## @strong{Outputs} ## @table @var @@ -126,7 +131,7 @@ error ("bode: invalid value of plot_style specified"); endif - [f, w] = __bodquist__ (sys, w, outputs, inputs, "bode"); + [f, w, sys] = __bodquist__ (sys, w, outputs, inputs, "bode"); [stname,inname,outname] = sysgetsignals(sys); systsam = sysgettsam(sys);
--- a/scripts/control/base/nichols.m +++ b/scripts/control/base/nichols.m @@ -37,8 +37,8 @@ ## (3) A "smoothing" routine is used to ensure that the plot phase does ## not change excessively from point to point and that singular ## points (e.g., crossovers from +/- 180) are accurately shown. -## outputs, inputs: the indices of the output(s) and input(s) to be used in -## the frequency response; see sysprune. +## outputs, inputs: the names or indices of the output(s) and input(s) +## to be used in the frequency response; see sysprune. ## outputs: ## mag, phase: the magnitude and phase of the frequency response ## G(jw) or G(exp(jwT)) at the selected frequency values. @@ -67,7 +67,7 @@ inputs = []; endif - [f, w] = __bodquist__ (sys, w, outputs, inputs, "nichols"); + [f, w, sys] = __bodquist__ (sys, w, outputs, inputs, "nichols"); [stname,inname,outname] = sysgetsignals(sys); systsam = sysgettsam(sys);
--- a/scripts/control/base/nyquist.m +++ b/scripts/control/base/nyquist.m @@ -119,7 +119,7 @@ ## signal to __bodquist__ who's calling - [f, w] = __bodquist__ (sys, w, outputs, inputs, "nyquist"); + [f, w, sys] = __bodquist__ (sys, w, outputs, inputs, "nyquist"); ## Get the real and imaginary part of f. realp = real(f);
--- a/scripts/control/system/sysprune.m +++ b/scripts/control/system/sysprune.m @@ -1,4 +1,4 @@ -## Copyright (C) 1996, 1998 Auburn University. All rights reserved. +## Copyright (C) 1996, 1998, 2000 Auburn University. All rights reserved. ## ## This file is part of Octave. ## @@ -26,9 +26,16 @@ ## system data structure ## @item out_idx ## @itemx in_idx -## list of connections indices; the new -## system has outputs y(out_idx(ii)) and inputs u(in_idx(ii)). +## +## Indices or signal names of the outputs and inputs to be kept in the returned +## system; remaining connections are "pruned" off. ## May select as [] (empty matrix) to specify all outputs/inputs. +## +## @example +## retsys = sysprune(Asys,[1:3,4],"u_1"); +## retsys = sysprune(Asys,list("tx","ty","tz"), 4); +## @end example +## ## @end table ## ## @strong{Outputs} @@ -62,6 +69,14 @@ if(isempty(input_idx)) input_idx = 1:mm; endif if(isempty(state_idx)) state_idx = 1:(nn+nz); endif + ## check for signal names + if(is_signal_list(output_idx) | isstr(output_idx)) + output_idx = sysidx(sys,"out",output_idx); + endif + if(is_signal_list(input_idx) | isstr(input_idx)) + input_idx = sysidx(sys,"in",input_idx); + endif + ## check dimensions if( !(is_vector(output_idx) | isempty(output_idx) ) ) if(!is_matrix(output_idx))