bugGNU Octave - Bugs: bug #66377, [Control Package] Problem...

 
 

bug #66377: [Control Package] Problem declaring Transfer Functions with imaginary components

Submitter:  Luiz Antonio Maccari Junior <luiz>
Submitted:  Fri 25 Oct 2024 12:30:40 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Ready For Test Assigned to:  None
Originator Name:  Luiz Antonio Maccari Jr. Open/Closed:  * Open
Release:  * 9.2.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 09 Dec 2024 05:57:01 AM UTC, comment #12: 

I have pushed some commits to the dev-branch of the control package repository at https://github.com/gnu-octave/pkg-control which allows to enter imaginary coefficients when defining a transfer function.

However, especially when entering a transfer function as a combination of smaller subsystems, there is no possibility to distinguish between intermediate and final forms of the transfer systems. Therefore, also the final result is now allowed to have imaginary coefficients. Since many methods do not work correctly for imaginary coefficients, a warning is displayed whenever an imaginary coefficient is detected.

Torsten Lilge <ttl>
Group Member
Sun 27 Oct 2024 05:28:30 PM UTC, comment #11: 

@Torsten: I really don't remember when was the last time I used this function with imaginary terms. But it seems
it was after 2019.

Luiz Antonio Maccari Junior <luiz>
Sun 27 Oct 2024 02:05:46 AM UTC, comment #10: 

I think we could try
isnumeric
instead of
isreal

Doug Stewart <dastew>
Sat 26 Oct 2024 04:59:13 PM UTC, comment #9: 

I have been testing with Octave 9.2 and the Control Package back to version 3.2.0, always with the same error. Unfortunately, between version 3.1.0 and 3.2.0 there was a change in exactly the relevant part of the code (is_real_matrix.cc) from the octave_value method is_real_type() to isreal() for Octave 5 and later on to   the macro OV_REAL for backward compatibility.

In order to allow defining a transfer function with (intermediate) complex coefficients, we could just test for numeric values and drop the test for real values.

@Luiz: Since 3.2.0 ist already quite old (April 2019), could it be that previous cases where the transfer function was defined using "s", there only were real coefficients involved?

Torsten Lilge <ttl>
Group Member
Sat 26 Oct 2024 12:50:03 AM UTC, comment #8: 

It is the sane in octave 8.4, 9.2.1 and 10.0.0 (control 4.0.1)

octave:3> pkg load control
octave:4> s = tf('s');
octave:5> FT = (s+4)/((s+4j)*(s-4j))
error: tf: numerator 'num' must be a real-valued, non-empty vector or a cell of such vectors
error: called from
    __adjust_tf_data__ at line 75 column 5
    tf at line 223 column 27
    __numeric_to_lti__ at line 36 column 16
    __sys_group__ at line 30 column 16
    plus at line 45 column 7
octave:6> ver
----------------------------------------------------------------------
GNU Octave Version: 8.4.0 (hg id: 78c13a2594f3)
GNU Octave License: GNU General Public License
Operating System: Linux 5.14.0-522.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Oct 20 13:04:34 UTC 2024 x86_64
----------------------------------------------------------------------
Package Name  | Version | Installation directory
--------------+---------+-----------------------
     control *|   4.0.1 | /home/dima/.local/share/octave/api-v58/packages/control-4.0.1


Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 25 Oct 2024 10:22:58 PM UTC, comment #7: 

I don't remember well. But think it was 3.5.0 or below. It would be interesting to test also in octave 8. Next week I can test in an older version at my university.

Luiz Antonio Maccari Junior <luiz>
Fri 25 Oct 2024 09:03:59 PM UTC, comment #6: 

The error also shows up in control 3.6.0.

Do you know with which version of the control package this kind of command (including complex coefficients) were running for you?

Torsten Lilge <ttl>
Group Member
Fri 25 Oct 2024 03:27:41 PM UTC, comment #5: 

I am going to look at this over the weekend. As this issue showed up in a recent version of Octave (I guess the related recent version of the control package is to blame), there must be a change that broke this. Maybe

__adjust_tf_data__

wasn't called in this case or I have change the file itself.

Torsten Lilge <ttl>
Group Member
Fri 25 Oct 2024 03:17:28 PM UTC, comment #4: 



In  _adjust_tf_data at line 33 we have
  elseif (is_real_matrix (num))

but the value is a complex number so it returns false
and we need a true.

I don't see a is_double_matrix or an is_complex_matrix
so how should we fix this.


Doug Stewart <dastew>
Fri 25 Oct 2024 01:52:07 PM UTC, comment #3: 

I can confirm your error and am trouble shooting it now.

Doug Stewart <dastew>
Fri 25 Oct 2024 01:32:53 PM UTC, comment #2: 

Hi. The required outputs are:

>> which tf

'tf' is a function from the file /home/luiz/.local/share/octave/api-v59/packages/control-4.0.1/@tf/tf.m


>> whos

Variables visible from the current scope:

variables in scope: top scope

  Attr   Name        Size                     Bytes  Class
  ====   ====        ====                     =====  =====
         ans         1x1                          8  double
         s           1x1                         34  tf

Total is 2 elements using 42 bytes

Luiz Antonio Maccari Junior <luiz>
Fri 25 Oct 2024 01:24:39 PM UTC, comment #1: 

to help us trouble shoot your problem try:

which tf
 also show us what whos shows for s after running your code.


Doug Stewart <dastew>
Fri 25 Oct 2024 12:30:40 PM UTC, original submission:  

Hi,

I'm used to declare transfer functions following the below statement:




s = tf('s');

FT = (s+4)/((s+4j)*(s-4j))


However in the octave 9.2 I am getting the error messsage:

error: tf: numerator 'num' must be a real-valued, non-empty vector or a cell of such vectors
error: called from
    _adjust_tf_data_ at line 75 column 5
    tf at line 223 column 27
    _numeric_to_lti_ at line 36 column 16
    _sys_group_ at line 30 column 16
    plus at line 45 column 7
    teste at line 3 column 4

On previous versions these type of statements were working well.

I am using Octave 9.2 and the problem is appearing in Linux Mint 22 (Ubuntu 24.04) as well in windows 11.

The control toolbox version is 4.0.1


Just to compare, running the same code in Matlab I got the expected output



FT =

   s + 4
  --------
  s^2 + 16

Continuous-time transfer function.
Model Properties


Best Regards.

Luiz Antonio Maccari Junior <luiz>

 

(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 dasergatskov (Posted a comment)
  • -email is unavailable- added by ttl (Posted a comment)
  • -email is unavailable- added by dastew (Posted a comment)
  • -email is unavailable- added by luiz (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.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-12-09 ttl StatusNone Ready For Test

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code