bugGNU Octave - Bugs: bug #44949, control package: rlocus gives...

 
 

bug #44949: control package: rlocus gives discontinuous data

Submitter:  None
Submitted:  Tue 28 Apr 2015 07:10:49 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Sebastien Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * other
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 15 Jun 2015 06:04:23 AM UTC, comment #12: 

Thanks! This fixes it for me, too.

Lukas Reichlin <paramaniac>
Mon 15 Jun 2015 05:29:22 AM UTC, comment #11: 

on line 219
change to
    rlpol(1:nroots,ii) = vec(crootssort (roots (den + gain*num)));


Im not sure what your sort_roots is called so I show it with my name

This fixes it for my system

Doug Stewart <dastew>
Mon 15 Jun 2015 05:14:22 AM UTC, comment #10: 

I made a silly mistake (two functions with the same name) and corrected it:

https://bitbucket.org/paramaniac/control/commits/d350b3e9b3426a9dbc56f4dd9532004da38f6d43

Furthermore, I found a system which still gives discontinuous plots:


sys = tf ([1 0 0 0 0 0 1], [1 0 0 0 1 0 0 0 0 1])
rlocus (sys)


The plot from the rlocus function released with control-2.8.1 used to look better in this case.

Any ideas? Thanks for any hints!

Lukas Reichlin <paramaniac>
Sun 14 Jun 2015 03:02:03 PM UTC, comment #9: 

Thank you very much for your help, guys! I've pushed a changeset:

https://bitbucket.org/paramaniac/control/commits/657fdd77f224cce75392c3d8ecf7ea15f92c4bae


Lukas Reichlin <paramaniac>
Thu 11 Jun 2015 06:02:55 PM UTC, comment #8: 

I looked at this some more and decided that the complex part should be sorted by the regular sort.

see attached file

(file #34205)

Doug Stewart <dastew>
Wed 10 Jun 2015 02:29:46 PM UTC, comment #7: 

I just looked at matlab online help and it says:

If A is complex, then sort(A) sorts the elements by magnitude. If more than one element has equal magnitude, the elements are sorted by phase angle on the interval [−π, π].

So I think we should treat this as a special case.

Lukas --> it is your final call.

Doug Stewart <dastew>
Wed 10 Jun 2015 01:58:43 PM UTC, comment #6: 

I am not sure what matlab does.(I don't have matlab)
and I am not sure what is the "correct way" of sorting complex numbers is. I just know that this is the sort that is needed for this operation in this function (rlocus.m).

Doug Stewart <dastew>
Wed 10 Jun 2015 01:44:08 PM UTC, comment #5: 

So this has to do with the way that Octave defines sorting for complex numbers, and not compatible with Matlab's sort. Octave sorts complex numbers by magnitude first, then by phase. Matlab sorts complex numbers by real part first.

Mike Miller <mtmiller>
Group Member
Wed 10 Jun 2015 01:18:11 PM UTC, comment #4: 

I have a solution to this problem that works for me.
I created a new function called
crootssort.m    see attached file.
I then changed line 174 from

 rlpol(1:nroots,ii) = vec(sort (roots (den + gain*num)));

to
 rlpol(1:nroots,ii) = vec(crootssort (roots (den + gain*num)));
and now it works for me.



(file #34196)

Doug Stewart <dastew>
Wed 10 Jun 2015 08:56:27 AM UTC, comment #3: 

Thanks for reporting, but I'm afraid that I don't know how to fix this at the moment.

Lukas Reichlin <paramaniac>
Tue 28 Apr 2015 10:02:52 PM UTC, comment #2: 

this shows that the order of the roots changes as the gain increases:
for a = 23:1:26
a
roots([1 9 (a+18) (4*a)])
abs(roots([1 9 (a+18) (4*a)]))
endfor


Doug Stewart <dastew>
Tue 28 Apr 2015 08:24:19 PM UTC, comment #1: 

I can confirm this with rc3.

I did some digging anf found that what is happening is that the roots to plot are changing order as can be seen here:
Columns 124 through 126:

  -4.91518 + 0.00000i  -4.91220 + 0.00000i  -2.04537 + 4.47197i
  -2.04241 + 4.42627i  -2.04390 + 4.44917i  -4.90925 + 0.00000i
  -2.04241 - 4.42627i  -2.04390 - 4.44917i  -2.04537 - 4.47197i

 Columns 127 and 128:

  -2.04682 + 4.49466i  -2.04826 + 4.51726i
  -4.90635 + 0.00000i  -4.90349 + 0.00000i
  -2.04682 - 4.49466i  -2.04826 - 4.51726i

>>


 In col. 125 and 126 we can see that the real branch has moved from first in the list to second, and thus the plot has the funny lines in it.

I ran this line to get this data:
[rldata_pd k_list_pd] = rlocus(G_pd*G, 0.21, 0,  26.);


Doug Stewart <dastew>
Tue 28 Apr 2015 07:10:49 PM UTC, original submission:  

When running the following program


clear all

%get some system
s = tf('s');
G = 1/(s*(s+3)*(s+6));

%get root locust data
[rldata, k_list] = rlocus(G, 0.01, 0, 40);

%define some controler
Z_CI=4.52921067560045;
G_pd = (s+Z_CI);

%get root locust data
[rldata_pd k_list_pd] = rlocus(G_pd*G, 0.01, 0, 40);


The data contained in rldata_pd is scrambled such that starting at index 2628, row 1 and 2 are inverted, causing a discontinuous vector. The result of


%the plot is discontinuous
rldata_pd(1,2627:2628)
rldata_pd(2,2627:2628)


show that behaviour and displays


ans =

  -4.91792703087913 + 0.00000000000000i  -2.04110517684489 + 4.47493066843290i

ans =

  -2.04103648456044 + 4.47385708453766i  -4.91778964631022 + 0.00000000000000i


This can also be replicated when a single argument is given to rlocus, but the location of the crossover point will be different.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #34205:  crootssort.m added by dastew (319B - text/x-objcsrc)
file #34196:  crootssort.m added by dastew (350B - text/x-objcsrc)
file #33828:  mwe.m added by None (545B - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by paramaniac (Posted a comment)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by mtmiller
  • -email is unavailable- added by dastew (Posted a comment)
  • -email is unavailable- added by None (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 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-06-17 mtmiller StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-06-11 dastew Attached File- Added crootssort.m, #34205
    2015-06-10 dastew Attached File- Added crootssort.m, #34196
    2015-06-03 mtmiller StatusNone Confirmed
        Release3.8.1 other
        Summaryrlocus gives discontinuous data control package: rlocus gives discontinuous data
        Carbon-Copy- Added paramaniac
    2015-04-28 rik5 Carbon-CopyRemoved 72865 -
    2015-04-28 rik5 CategoryOctave Function Octave Package
    2015-04-28 None Attached File- Added mwe.m, #33828

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code