bugGNU Octave - Bugs: bug #43586, control package: tf function...

 
 

bug #43586: control package: tf function accepts any string as the variable name

Submitter:  Arnaud Miege <am304>
Submitted:  Wed 12 Nov 2014 10:57:13 AM UTC
   
 
Category:  Octave Package Severity:  2 - Minor
Priority:  3 - Low Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * other Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 18 Oct 2015 04:57:51 PM UTC, comment #6: 

In recent development version, I restricted the transfer function variable to 's', 'p' for continuous-time and 'z', 'q', 'z^-1', 'q^-1' for discrete-time models.

Until I release an official version, you can download a snapshot from here:

http://sourceforge.net/p/octave/control/ci/default/tree/

Accordingly, this bug report can be closed.

Lukas Reichlin <paramaniac>
Fri 19 Jun 2015 01:57:15 PM UTC, comment #5: 

So it looks like Matlab strictly validates the string given to the tf function and it probably has to exactly match one of the allowed "variable" strings 's', 'z', 'p', 'q', 'z^-1', or 'q^-1'.

Since any other string is disallowed by Matlab, there's no harm in accepting other strings in the control package for compatibility.

It's up the control package maintainer whether more strict checks should be added for the variable name string, or whether it's documented clearly enough as is.

Mike Miller <mtmiller>
Group Member
Tue 16 Jun 2015 08:05:04 PM UTC, comment #4: 

Output from Matlab 2015a:


>> s = tf('s')


s =
 
  s
 
Continuous-time transfer function.

>> s=tf('string')

Error using tf (line 241)
Invalid syntax. The first input argument of
the "tf" command cannot be a string.
 

>> s=tf('1/(s+1)')

Error using tf (line 241)
Invalid syntax. The first input argument of
the "tf" command cannot be a string.
 

>> s=tf('a')

Error using tf (line 241)
Invalid syntax. The first input argument of
the "tf" command cannot be a string.

Nicholas Jankowski <nrjank>
Group Member
Thu 15 Jan 2015 02:34:21 AM UTC, comment #3: 

I think it would be useful to get someone to show what Matlab does with


s=tf('s')
s=tf('string')
s=tf('1/(s+1)')
s=tf('a')


According to http://www.mathworks.com/help/control/ref/tf.html, the  tf object Variable property is allowed to be one of the strings 's', 'z', 'p', 'q', 'z^-1', or 'q^-1', but it doesn't say what Matlab does if you try to use a different string.

Mike Miller <mtmiller>
Group Member
Fri 02 Jan 2015 11:17:57 PM UTC, comment #2: 

Can we close this report as invalid?

Andreas Weber <andy1978>
Group Member
Sat 22 Nov 2014 11:45:07 AM UTC, comment #1: 

The tf function accepts any string as transfer function variable, even '1/(s+1)':


octave:2> s = tf ('1/(s+1)')

Transfer function 's' from input 'u1' to output ...

 y1:  1/(s+1)

Continuous-time model.
octave:3> sys = (s - 1)/(s^2 + 2*s + 1)

Transfer function 'sys' from input 'u1' to output ...

             1/(s+1) - 1
 y1:  -------------------------
      1/(s+1)^2 + 2 1/(s+1) + 1

Continuous-time model.
octave:4> s = tf ('string')

Transfer function 's' from input 'u1' to output ...

 y1:  string

Continuous-time model.
octave:5> sys = (s - 1)/(s^2 + 2*s + 1)

Transfer function 'sys' from input 'u1' to output ...

            string - 1
 y1:  -----------------------
      string^2 + 2 string + 1

Continuous-time model.
octave:6>


This can be useful, but also very misleading. As you can see below, the result of your system c is always computed correctly:


octave:9> s = tf ('string')

Transfer function 's' from input 'u1' to output ...

 y1:  string

Continuous-time model.
octave:10> s(1)
ans =  0 + 1i
octave:11> s = tf ('s')

Transfer function 's' from input 'u1' to output ...

 y1:  s

Continuous-time model.
octave:12> s(1)
ans =  0 + 1i
octave:13>


One could argue that only 's' and 'z' (and maybe 'p' and 'q' for time domain) should be accepted by tf, though.

Lukas Reichlin <paramaniac>
Wed 12 Nov 2014 10:57:13 AM UTC, original submission:  

The tf function from the control package can output the wrong result if the transfer function is not correctly entered, and it does not error out. The details can be found at this StackOverflow question but in essence, it boils down to the following:


>> a = tf(1,[1 1])

Transfer function 'a' from input 'u1' to output ...

        1
 y1:  -----
      s + 1

Continuous-time model.
>> a(1)
ans =  0.50000 - 0.50000i
>> b = 1/(tf('s')+1)

Transfer function 'b' from input 'u1' to output ...

        1
 y1:  -----
      s + 1

Continuous-time model.
>> b(1)
ans =  0.50000 - 0.50000i
>> c = tf('1/(s+1)')

Transfer function 'c' from input 'u1' to output ...

 y1:  1/(s+1)

Continuous-time model.
>> c(1)
ans =  0 + 1i
>> s = tf('s')

Transfer function 's' from input 'u1' to output ...

 y1:  s

Continuous-time model.
>> d = 1/(s+1)

Transfer function 'd' from input 'u1' to output ...

        1
 y1:  -----
      s + 1

Continuous-time model.
>> d(1)
ans =  0.50000 - 0.50000i


c is incorrectly defined, but Octave does error out when doing so, and it then reports the wrong result.


Arnaud Miege <am304>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by andy1978 (Posted a comment)
  • -email is unavailable- added by paramaniac (Posted a comment)
  • -email is unavailable- added by am304 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-10-19 mtmiller StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2015-06-19 mtmiller Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        Item GroupIncorrect Result Documentation
        Release3.8.0 other
        Summarycontrol package: tf function outputs wrong results control package: tf function accepts any string as the variable name
    2015-01-15 mtmiller StatusNone Need Info
        Operating SystemMicrosoft Windows Any
        Summarytf function outputs wrong results control package: tf function outputs wrong results

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code