bugGNU Octave - Bugs: bug #62186, [Octave Forge](Control) 'bode'...

 
 

bug #62186: [Octave Forge](Control) 'bode' produces plots with inappropriate frequency ranges

Submitter:  None
Submitted:  Tue 15 Mar 2022 03:01:47 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Fixed Assigned to:  None
Originator Name:  Chris Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 6.4.0
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 20 Mar 2022 04:58:21 PM UTC, comment #4: 

Many thanks for fixing this issue.

Anonymous
Sun 20 Mar 2022 04:56:42 PM UTC, comment #3: 

This is fixed with commit https://sourceforge.net/p/octave/control/ci/ef354da92bcbf23f656268f4beec200d723a838b/ in the stable branch of the control package repository. It will be included in the next release.

I think this patch is more suitable than the one I have posted before. You cann make the change manually to _frequqnecy_vector_.m if you have write acces to the install location of the control package.

Torsten Lilge <ttl>
Group Member
Thu 17 Mar 2022 09:15:16 PM UTC, comment #2: 

Thank you for your explanation and for the patch.

Anonymous
Thu 17 Mar 2022 07:51:27 PM UTC, comment #1: 

Thank you for the report. I think the cause for this behavior is that, due to numerical issues, the zeros of system(3,1) are not located at the origin of the complex plane but at

-7.8505e-16 + 5.6037e-08i
-7.8505e-16 - 5.6037e-08i

which causes bode() to compute a strange frequency range in order to include these zeros.

Please find below a patch for __frequency_vector__.m, which can be edited by "edit __frequency_vector__":


@@ -138,8 +138,8 @@
     endif
   else
     ## continuous
-    iip = find (abs(pol) > norm(pol)*eps);
-    iiz = find (abs(zer) > norm(zer)*eps);
+    iip = find ((abs(pol) > eps) && (abs(pol) > norm(pol)*eps));
+    iiz = find ((abs(zer) > eps) && (abs(zer) > norm(zer)*eps));

     if (! isempty (zer))
       czer = zer(iiz);


With this patch applied, zeros and poles are included in the frequency range if they are relevant relative to the norm of the vector of all zeros and poles resp. and, which is new,  if the zeros and poles are absolutely relevant, too. I am not yet totally sure if there might be unwanted side effects in other cases.

cc-ing Doug since he is currently working on a bug related to the bode function, too.

Torsten Lilge <ttl>
Group Member
Tue 15 Mar 2022 03:01:47 AM UTC, original submission:  

For the second order state-space system below, function 'bode' produces an incorrectly presented plot, i.e. the X-axis lower limit is much lower than necessary and the lower bound of the plot is shown with no data points present at lower frequencies. See attached image.


m = 1.0     % Mass
k = 10.0    % Spring constant
b = 1      % Damping constant

% State-space model of the mass-spring-damper system

A = [0 1;...
     -k/m -b/m]

B = [0;...
    -1/m]

C = [1 0;...
     0 1;...
     -k/m -b/m]

D = [0;
     0;
     -1/m]

states = {'Position' 'Velocity'}
inputs = {'Force'}
outputs = {'Position' 'Velocity' 'Acceleration'}

system = ss(A,B,C,D,'statename',states,...
'inputname', inputs,...
'outputname', outputs)

% Time-domain responses

% Impulse responses

figure()
impulse(system(1,1))

figure()
impulse(system(2,1))

% figure()
% impulse(system(3,1))

% Step responses

figure()
step(system(1,1))

figure()
step(system(2,1))

figure()
step(system(3,1))

% Pole-zero maps

figure()
pzmap(system(1,1))

% Bode plot

figure()
bode(system(1,1));  % Force to Position
title('Bode: Force to Position')

figure()
bode(system(2,1));  % Force to Velocity
title('Bode: Force to Velocity')

figure()
bode(system(3,1));  % Force to Acceleration
title('Bode: Force to Acceleration')


Matlab (version info below) is able to produce a properly scaled plot (see attached image).


MATLAB Version: 9.11.0.1687835 (R2021b) Prerelease
MATLAB License Number: 865865
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 19044)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode


Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #52988:  Octave@Bode.PNG added by None (344KiB - image/png)
file #52989:  Matlab@Bode.PNG added by None (124KiB - image/png)

 

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 ttl
  • -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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-03-20 ttl StatusNone Fixed
        Open/ClosedOpen Closed
    2022-03-17 ttl Operating SystemMicrosoft Windows Any
        SummaryFunction 'bode' produces possibly correct but mis-presented result [Octave Forge](Control) 'bode' produces plots with inappropriate frequency ranges
        Carbon-Copy- Added -email is unavailable-
    2022-03-15 None Attached File- Added Octave@Bode.PNG, #52988
        Attached File- Added Matlab@Bode.PNG, #52989

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code