bugGNU Octave - Bugs: bug #58240, [octave-forge] (control) tf2ss...


bug #58240: [octave-forge] (control) tf2ss returns other state space representation than Matlab

Submitted by:  None
Submitted on:  Sat 25 Apr 2020 02:59:44 PM UTC  
Category:  Octave Forge Package Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  None Assigned to:  None
Originator Name:  Aleksandar Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  5.2.0
Operating System:  Microsoft Windows

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Wed 29 Apr 2020 08:02:18 PM UTC, comment #9: 

I have push a patch to forge that adds the transofrmation from octave's result form to matlab's form.

Torsten Lilge <ttl>
Project Member
Sun 26 Apr 2020 06:37:48 PM UTC, comment #8: 

Sure, I can add a note to the help of ssdata. Should we also add this flag for matlab compatibility. This should also be added to tf2ss in the signal package.

Btw: Why does "help tf" work but not "help ssdata" where "help @lti/ssdata" has to be used?

Torsten Lilge <ttl>
Project Member
Sun 26 Apr 2020 05:51:49 PM UTC, comment #7: 

how about putting a note in the help section telling them how to convert.

Doug Stewart <dastew>
Sun 26 Apr 2020 03:55:28 PM UTC, comment #6: 

I just had a look into the Matlab help for this function and there is no hint on the specific representation that is returned. Therefore I am not sure if the user can expect a specific representation, neither in Octave nor in Matlab, and if the returned form may change in the future. So, if we change the behavior, I also suggest the switch.

I realized that tf2ss is part of the signal package but ssdata gives the same representation as tf2ss does.

Torsten Lilge <ttl>
Project Member
Sun 26 Apr 2020 02:40:17 PM UTC, comment #5: 

@Torsten, I think that the switch is a great solution (as long as it is easily visible).

Aleksandar <aleksandar>
Sun 26 Apr 2020 01:31:45 PM UTC, comment #4: 

@Torsten and others:
Should we :
implement the suggested code from comment #3 to make it alwasy give Matlab answers?
Put a matlab compatibility switch in so we can maintain the present way and select the matlab way if it is wanted?

Doug Stewart <dastew>
Sun 26 Apr 2020 10:37:31 AM UTC, comment #3: 

Aleksandar, you said in your original post that the result in octave is not a correct answer. But it is correct. A dynamical system generally has exactly one transfer function but an infinity large number of possible state space representations. Octave's state space representation leads to the original transfer function.

The state space representation that you have given for Matlab does not result in the original transfer function but in num = [1 4], den = [1 4 -3]. The correct matrix should be A1 = [ -4 -3 ; 1 0 ], I guess this is a typo in your post?

Given that A1 is the above matrix in Matlab, then the similarity transformation T = [-4 -13 ; 1 4 ] transforms the state space representation from Matlab into the one from Octave, i.e. A_oct = T*A_mat*inv(T), B_oct = T*B_mat, C_oct = C_mat*inv(T).

I am changing the item group into "Matlab Compatibility" and the Severity into minor.

Torsten Lilge <ttl>
Project Member
Sat 25 Apr 2020 05:00:20 PM UTC, comment #2: 

My original bug report was just explaining that Matlab returns different result than Octave for the same function (tf2ss) and that the result from Matlab is consistent to the result that we obtained 'on paper' in mu classes for the transfer function in complex domain that is stated in example code in my original message. Therefore, I am forced to use Matlab, although I prefer Octave otherwise.
Your answer is not resolving the issue from my original message.

Aleksandar <aleksandar>
Sat 25 Apr 2020 03:21:13 PM UTC, comment #1: 

There are many ways of representing a system in State space.
After you have your state space  model, Does it give a correct
step response?
impulse response?
Bode response?

Doug Stewart <dastew>
Sat 25 Apr 2020 02:59:44 PM UTC, original submission:  

As a student I am using tf2ss(num,den) in signal conversion from transfer function to a state space matrix and we have done it on paper and later on using software. Example code is:

close all; clear all; clc;
num = [1 4]; den = [1 4 3];
[A1, B1, C1, D1] = tf2ss(num, den);

it returns

A1 =
   4.4409e-16   3.0000e+00
  -1.0000e+00  -4.0000e+00
B1 = -4.000   1.0000
C1 = 0  1

(this one is not a correct answer)

Matlab, with same code returns

A1 = -4   3
      1   0
B1 =  1   0
C1 =  1   4

(this one is the same as we did on paper)

Maybe this is useful to you, so you can fix that.



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

Attach Files:

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 ttl (Posted a comment)
  • -email is unavailable- added by aleksandar (Posted a comment)
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by dastew (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-04-26 ttl Summary[octave-forge] (control) Function tf2ss in Octave returns wrong result (in Matlab same function works OK) => [octave-forge] (control) tf2ss returns other state space representation than Matlab
    2020-04-26 ttl Severity3 - Normal => 2 - Minor
        Item GroupIncorrect Result => Matlab Compatibility
    2020-04-25 jwe SummaryFunction tf2ss in Octave returns wrong result (in Matlab same function works OK) => [octave-forge] (control) Function tf2ss in Octave returns wrong result (in Matlab same function works OK)

    Back to the top

    Powered by Savane 3.5