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

 
 

bug #44949: control package: rlocus gives discontinuous data

Submitted by:  None
Submitted on:  Tue 28 Apr 2015 07:10:49 PM UTC  
 
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: SebastienOriginator Email: -unavailable-
Open/Closed: ClosedRelease: other
Operating System: GNU/Linux

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 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:

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>
Project Administrator
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

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

show that behaviour and displays

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 File(s):
   
   
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
  • -unavailable- added by paramaniac (Posted a comment)
  • -unavailable- added by mtmiller (Updated the item)
  • -unavailable- added by mtmiller
  • -unavailable- added by dastew (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 11 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 17 Jun 2015 03:04:24 PM UTCmtmillerStatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Thu 11 Jun 2015 06:02:55 PM UTCdastewAttached File-=>Added crootssort.m, #34205
    Wed 10 Jun 2015 01:18:11 PM UTCdastewAttached File-=>Added crootssort.m, #34196
    Wed 03 Jun 2015 02:02:14 AM UTCmtmillerStatusNone=>Confirmed
      Release3.8.1=>other
      Summaryrlocus gives discontinuous data=>control package: rlocus gives discontinuous data
      Carbon-Copy-=>Added paramaniac
    Tue 28 Apr 2015 08:17:13 PM UTCrik5Carbon-CopyRemoved 72865=>-
    Tue 28 Apr 2015 08:17:04 PM UTCrik5CategoryOctave Function=>Octave Forge Package
    Tue 28 Apr 2015 07:10:49 PM UTCNoneAttached File-=>Added mwe.m, #33828

    Back to the top


    Powered by Savane 3.1-cleanup1