File: feedback.m

package info (click to toggle)
octave-control 1.0.11-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,628 kB
  • ctags: 160
  • sloc: makefile: 64; sh: 4
file content (44 lines) | stat: -rw-r--r-- 1,413 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## Copyright (C) 2000 Ben Sapp.  All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by the
## Free Software Foundation; either version 2, or (at your option) any
## later version.
##
## This is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
## for more details.

## feedback(sys1,sys2)
##
## Filter the output of sys1 through sys2 and subtract it from the input.
##
##              _____________
##     +        |            |
## u --->0----->|    sys1    |------->
##       |-     |____________|   |
##       |                       |
##       |      _____________    |
##       |      |            |   |
##       -------|    sys2    |----
##              |____________|
##
## This only works for SISO systems.
 
## Author: Ben Sapp <bsapp@lanl.gov>
 
function out = feedback(sys1,sys2)
  if (nargin != 2)
    error("only 2 arguements accepted");
  endif
  if(!is_siso(sys1) || !is_siso(sys2))
    error("only single input single output systems supported");
  endif
  T = sysgroup(sys1,sys2);
  T = sysdup(T,2,[]);
  T = sysscale(T,diag([1,1,-1]),[]);
  T = sysconnect(T,3,1);
  T = sysconnect(T,1,2);
  out = sysprune(T,1,1);
endfunction