home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / r / rlab / CTB / tfchk < prev    next >
Encoding:
Text File  |  1995-11-15  |  1.4 KB  |  53 lines

  1. //------------------------------------------------------------------------------
  2. //
  3. // tfchk
  4. //
  5. // Syntax: a=tfchk(num,den)
  6. //
  7. // This routine checks the transfer function given in (num,den) where
  8. // num is the numerator and den is the denominator. The routine passes
  9. // back the transfer function in a list.
  10. //
  11. // If the transfer function is not proper given by (num,den) then
  12. // it returns lenth(numc) = length(denc).
  13. //
  14. // The returned list for a=tfchk(num,den) is:
  15. //
  16. //       a.numc = correct numerator
  17. //       a.denc = correct denominator
  18. //
  19. // Copyright (C), by Jeffrey B. Layton, 1994
  20. // Version JBL 931016
  21. //------------------------------------------------------------------------------
  22.  
  23. rfile isempty
  24.  
  25. tfchk = function(num,den)
  26. {
  27.    local(numc,denc)
  28.  
  29. // Check for empty matrices
  30.    if ( (isempty(num)) || (isempty(den))) {
  31.         error("TFCHK: Warning: Transfer function polynomials are empty.");
  32.    }
  33.  
  34. // Make sure den is a row vector, den is assumed to be in rows.
  35.    if ( !( (den.nr == 1) || (den.nc == 1)) ) {
  36.        error("TFCHK: Denominator must be a row vector.");
  37.    }
  38.  
  39.    if ( (den.nr != 1) && (den.nc == 1)) {
  40.        error("TFCHK: Tenominator must be a row vector.");
  41.    }
  42.  
  43.    if (num.nc > den.nc) {
  44.        error("TFCHK: Transfer function is not proper.");
  45.    }
  46.  
  47. // Make num and den lengths equal.
  48.    numc=[zeros(num.nr,den.nc-num.nc),num];
  49.    denc=den;
  50.  
  51.    return << numc=numc; denc=denc >>;
  52. };
  53.