changeset 8380:5c3f0c4d3803 octave-forge

control: improve texinfo help strings, fix a bug (thanks to Bernhard Weller)
author paramaniac
date Mon, 19 Sep 2011 14:05:34 +0000
parents 860bc03644fb
children 276bcadd42e6
files main/control/inst/@lti/tfdata.m main/control/inst/@tf/__get__.m main/control/inst/@tf/tf.m
diffstat 3 files changed, 68 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/main/control/inst/@lti/tfdata.m	Mon Sep 19 11:40:51 2011 +0000
+++ b/main/control/inst/@lti/tfdata.m	Mon Sep 19 14:05:34 2011 +0000
@@ -1,4 +1,4 @@
-## Copyright (C) 2009, 2010   Lukas F. Reichlin
+## Copyright (C) 2009, 2010, 2011   Lukas F. Reichlin
 ##
 ## This file is part of LTI Syncope.
 ##
@@ -19,11 +19,34 @@
 ## @deftypefn {Function File} {[@var{num}, @var{den}, @var{tsam}] =} tfdata (@var{sys})
 ## @deftypefnx {Function File} {[@var{num}, @var{den}, @var{tsam}] =} tfdata (@var{sys}, @var{"tfpoly"})
 ## Access transfer function data.
+## Argument @var{sys} is not limited to transfer function models.
+## If @var{sys} is not a transfer function, it is converted automatically.
+##
+## @strong{Inputs}
+## @table @var
+## @item sys
+## Any type of LTI model.
+## @end table
+##
+## @strong{Outputs}
+## @table @var
+## @item num
+## Cell of numerator(s).  Each numerator is a row vector
+## containing the coefficients of the polynomial in descending powers of
+## the transfer function variable.
+## @item den
+## Cell of denominator(s).  Each denominator is a row vector
+## containing the coefficients of the polynomial in descending powers of
+## the transfer function variable.
+## @item tsam
+## Sampling time in seconds.  If @var{sys} is a continuous-time model,
+## a zero is returned.
+## @end table
 ## @end deftypefn
 
 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
 ## Created: September 2009
-## Version: 0.2
+## Version: 0.3
 
 function [num, den, tsam] = tfdata (sys, rtype = "vector")
 
@@ -36,8 +59,8 @@
   tsam = sys.tsam;
 
   if (rtype(1) == "v")
-    num = cellfun ("@tfpoly/get", num, "uniformoutput", false);
-    den = cellfun ("@tfpoly/get", den, "uniformoutput", false);
+    num = cellfun (@get, num, "uniformoutput", false);
+    den = cellfun (@get, den, "uniformoutput", false);
   endif
 
-endfunction
\ No newline at end of file
+endfunction
--- a/main/control/inst/@tf/__get__.m	Mon Sep 19 11:40:51 2011 +0000
+++ b/main/control/inst/@tf/__get__.m	Mon Sep 19 14:05:34 2011 +0000
@@ -26,10 +26,10 @@
 
   switch (prop)  # {<internal name>, <user name>}
     case "num"
-      val = cellfun ("@tfpoly/get", sys.num, "uniformoutput", false);
+      val = cellfun (@get, sys.num, "uniformoutput", false);
 
     case "den"
-      val = cellfun ("@tfpoly/get", sys.den, "uniformoutput", false);
+      val = cellfun (@get, sys.den, "uniformoutput", false);
 
     case {"tfvar", "variable"}
       val = sys.tfvar;
@@ -38,4 +38,4 @@
       error ("tf: get: invalid property name");
   endswitch
 
-endfunction
\ No newline at end of file
+endfunction
--- a/main/control/inst/@tf/tf.m	Mon Sep 19 11:40:51 2011 +0000
+++ b/main/control/inst/@tf/tf.m	Mon Sep 19 14:05:34 2011 +0000
@@ -1,4 +1,4 @@
-## Copyright (C) 2009, 2010   Lukas F. Reichlin
+## Copyright (C) 2009, 2010, 2011   Lukas F. Reichlin
 ##
 ## This file is part of LTI Syncope.
 ##
@@ -29,10 +29,12 @@
 ## LTI model to be converted to transfer function.
 ## @item num
 ## Numerator or cell of numerators.  Each numerator must be a row vector
-## containing the exponents of the polynomial in descending order.
+## containing the coefficients of the polynomial in descending powers of
+## the transfer function variable.
 ## @item den
 ## Denominator or cell of denominators.  Each denominator must be a row vector
-## containing the exponents of the polynomial in descending order.
+## containing the coefficients of the polynomial in descending powers of
+## the transfer function variable.
 ## @item tsam
 ## Sampling time in seconds.  If @var{tsam} is not specified, a continuous-time
 ## model is assumed.
@@ -54,20 +56,49 @@
 ## octave:2> G = 1/(s+1)
 ##
 ## Transfer function "G" from input "u1" to output ...
+## 
 ##         1  
 ##  y1:  -----
 ##       s + 1
-##
+## 
+## Continuous-time model.
 ## octave:3> z = tf ("z", 0.2);
 ## octave:4> H = 0.095/(z-0.9)
 ## 
 ## Transfer function "H" from input "u1" to output ...
+## 
 ##        0.095 
 ##  y1:  -------
 ##       z - 0.9
 ## 
 ## Sampling time: 0.2 s
-## octave:5> 
+## Discrete-time model.
+## octave:5> num = @{[1, 5, 7], [1]; [1, 7], [1, 5, 5]@};
+## octave:6> den = @{[1, 5, 6], [1, 2]; [1, 8, 6], [1, 3, 2]@};
+## octave:7> sys = tf (num, den)
+## 
+## Transfer function "sys" from input "u1" to output ...
+## 
+##       s^2 + 5 s + 7
+##  y1:  -------------
+##       s^2 + 5 s + 6
+## 
+##           s + 7    
+##  y2:  -------------
+##       s^2 + 8 s + 6
+## 
+## Transfer function "sys" from input "u2" to output ...
+## 
+##         1  
+##  y1:  -----
+##       s + 2
+## 
+##       s^2 + 5 s + 5
+##  y2:  -------------
+##       s^2 + 3 s + 2
+## 
+## Continuous-time model.
+## octave:8> 
 ## @end group
 ## @end example
 ##
@@ -76,7 +107,7 @@
 
 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
 ## Created: September 2009
-## Version: 0.2
+## Version: 0.2.1
 
 function sys = tf (num = {}, den = {}, varargin)