/tags/R2008-02-16/main/ident/inst/poly2th.m

# · MATLAB · 70 lines · 67 code · 3 blank · 0 comment · 12 complexity · c868ea1a050e3af58472c674b4e7e12c MD5 · raw file

  1. ## Copyright (C) 2000 Paul Kienzle
  2. ##
  3. ## This program is free software; you can redistribute it and/or modify
  4. ## it under the terms of the GNU General Public License as published by
  5. ## the Free Software Foundation; either version 2 of the License, or
  6. ## (at your option) any later version.
  7. ##
  8. ## This program is distributed in the hope that it will be useful,
  9. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ## GNU General Public License for more details.
  12. ##
  13. ## You should have received a copy of the GNU General Public License
  14. ## along with this program; If not, see <http://www.gnu.org/licenses/>.
  15. ## -*- texinfo -*-
  16. ## @deftypefn {Function File} {} {poly2th (@var{a}, @var{b}, @var{c}, @var{d}, @var{f}, @var{v}, @var{T})}
  17. ##
  18. ## Represent the generalized Multi-Input, Single-Output (MISO) system
  19. ## defined as follows:
  20. ##
  21. ##
  22. ## @math{ A_j(q)y(t) = \sum_{i=1}^{bn} \left( \frac{B_i(q)}{F_i(q)} u_i(t) \right) + \frac{C(q)}{D(q)}e_j(t)}
  23. ## where
  24. ## e is white noise
  25. ## u is the input signal
  26. ## y is the output signal
  27. ##
  28. ## @var{v} is the variance on the noise (default is 1)
  29. ## @var{T} is the sampling interval (default is 1)
  30. ##
  31. ## @end deftypefn
  32. ## @seealso {mktheta, idsim}
  33. ## TODO: incorporate delays: if system is discrete (T>0), then delay for
  34. ## TODO: input i is the number of leading zeros in b(:,i)
  35. function th = poly2th(a,b,c,d,f,v,T)
  36. if nargin<1 || nargin>7,
  37. usage("th = poly2th(a,b,c,d,f,v,T)");
  38. endif
  39. th.a = a;
  40. if nargin<2, th.b=[]; else th.b = b; endif
  41. if nargin<3, th.c=1; else th.c=c; endif
  42. if nargin<4, th.d=1; else th.d=d; endif
  43. if nargin<5, th.f=[]; else th.f=f; endif
  44. if nargin<6, th.v=1; else th.v=v; endif
  45. if nargin<7, th.T=1; else th.T=T; endif
  46. if size(th.a,1) == 1, th.a = th.a.'; endif
  47. if size(th.b,1) == 1, th.b = th.b.'; endif
  48. if size(th.c,1) == 1, th.c = th.c.'; endif
  49. if size(th.d,1) == 1, th.d = th.d.'; endif
  50. if size(th.f,1) == 1, th.f = th.f.'; endif
  51. if isempty(th.f), th.f = ones(1,columns(th.b)); endif
  52. na = columns(th.a);
  53. nb = columns(th.b);
  54. nc = columns(th.c);
  55. nd = columns(th.d);
  56. nf = columns(th.f);
  57. if nf != nb
  58. error("poly2th f and b must have the same number of columns");
  59. endif
  60. if nc>1 || nd>1
  61. error("poly2th: c and d may only have one column");
  62. endif
  63. endfunction