bugGNU Octave - Bugs: bug #63393, [octave forge] (control) Bode plot...

 
 

bug #63393: [octave forge] (control) Bode plot problem. Different results between MATLAB and Octave.

Submitter:  Luiz Antonio Maccari Junior <luiz>
Submitted:  Mon 21 Nov 2022 01:57:52 PM UTC
 
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  Confirmed Assigned to:  None
Originator Name:  Luiz Antonio Maccari Jr. Open/Closed:  * Open
Release:  * 7.2.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

( Jump to the original submission )

Mon 21 Nov 2022 08:47:32 PM UTC, comment #11: 

I took a look at what minreal was doing, and It was reducing the order of your filter. I think you should reduce the order of the filter  at the start rather than using minreal.

If you want to stay with that order of filter for your work then just use it and don't worry about what bode shows you. But also realize that the is a limit on using floating point resolution.

Doug Stewart <dastew>
Mon 21 Nov 2022 04:38:08 PM UTC, comment #10: 

I am sorry -- I misunderstood the report.
I can reproduce the problem.

The figure I attached earlier is
from the sample code  in comment #2 (with "minreal").

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Mon 21 Nov 2022 04:34:40 PM UTC, comment #9: 

I have tested here using the following command:

LD_PRELOAD=/lib/x86_64-linux-gnu/blas/libblas.so /home/luiz/my_octave/bin/octave --gui

The results are the same. I've got the result with noise.

Luiz Antonio Maccari Junior <luiz>
Mon 21 Nov 2022 04:08:54 PM UTC, comment #8: 

I am using now Linux Mint 20.3. I have built it following the instruction on octave wiki.

https://wiki.octave.org/Building

It is important to notice that the problem that I've reported was found also on windows 10 with the version 7.3.

Luiz Antonio Maccari Junior <luiz>
Mon 21 Nov 2022 04:05:18 PM UTC, comment #7: 

On Windows -- there is a blas switcher utility program is included with the installation. On Linux you can start octave as


LD_PRELOAD=/usr/lib64/libblas.so octave

(adjust the path to libblas.so as appropriate)

I think nn MacOS an equivalent would be DYLD_INSERT_LIBRARIES,
but I am not 100% sure.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Mon 21 Nov 2022 03:55:24 PM UTC, comment #6: 

for switching BLAS, which operating system are you using and how did you install octave?

Nicholas Jankowski <nrjank>
Project Member
Mon 21 Nov 2022 03:53:18 PM UTC, comment #5: 

regrading minreal not having help text or being viewable in edit, I assume you're referring to the Octave implementations?

Because of the way Octave has implemented these as class functions, you can't just check the functions with 'help minreal', even after loading the package.

'help @lti/minreal'  will diplay the (somewhat minimal) package help.  'edit @lti/minreal' will open the function for editing.  Note that it's handing off most of the functionality to @ss/___minreal___.m, which in turn will call other helper functions (located under @ss/) depending on the form of the input.

Also, note that if you wanted to debug/step through the functions, setting breakpoints is problematic as you need to be in the same folder as the function with the breakpoint, and that doesn't work well for class functions in a @/ folder. What you can do instead is have all of the relevant functions open in your editor, then add a 'keyboard' command in the first one called. from there you can step through the functions and into subfunctions using the toolbar or F10/F11 keys as needed.

Nicholas Jankowski <nrjank>
Project Member
Mon 21 Nov 2022 03:49:38 PM UTC, comment #4: 

Sorry I don't know how to do it. But if you give me the instructions to change BLAS Library, I could try.

Luiz Antonio Maccari Junior <luiz>
Mon 21 Nov 2022 03:43:47 PM UTC, comment #3: 

It looks OK (attached bode_das1.png) on linux octave 7.3.0 and control 3.4.0

(Control package seems to be sensitive to blas libraries. Could you try to change you blas from, presumably, openblas to reference blas?)

Dmitri.
--


Dmitri A. Sergatskov <dasergatskov>
Mon 21 Nov 2022 02:57:06 PM UTC, comment #2: 

The new code is:
-------------------------
load T.mat

Ts = 1/20000;

TF = tf(num,den,Ts)
TF=minreal(TF,0.1)

freq=[0.01:1:2*pi*(0.5/Ts)];

bode(TF,freq)

------------------------------

With the insertion of minreal the results are apparently the same. It seems that is not a bug on octave just a different type of behavior of the bode function.

Reasoning about the problem, I think that MATLAB is doing something not requested by the user. Maybe an warning or an explanation on the help should be interesting.

Sadly the function minreal does not have a help text and I cant open it using edit command.

Thank by attention.

Luiz Antonio Maccari Junior <luiz>
Mon 21 Nov 2022 02:42:33 PM UTC, comment #1: 

Hi,

I have made some tests using the function minreal with a nonstandard tolerance (tol=0,1). It seems that the bode function from MATLAB does this automatically and Octave bode doesn't.

On my point of view this bug report can be closed.

Thanks.

Luiz Antonio Maccari Junior <luiz>
Mon 21 Nov 2022 01:57:52 PM UTC, original submission:  

Dear developers,

I have found a different behavior from MATLAB and Octave bode function. I am taking the frequency response of a high-order discrete transfer function and getting different results from MATLAB (Bode_bug_matlab.jpg) and from octave (Bode_bug_octave.jpg).

As one can see, the Octave returns a frequency response with high-order (with noise) and MATLAB returns a filtered one (without noise).

On my interpretation, MATLAB is cancelling some pole and zeros inside a unknown precision range. However, I am not sure if the octave result is correct or it is just plotting something due to numeric errors.

All the files to reproduce the error are attached.

Thanks.

          

All files are attached.  

Luiz Antonio Maccari Junior <luiz>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #53986:  bode_das1.png added by dasergatskov (40KiB - image/png)
file #53981:  Bode_bug_matlab.jpg added by luiz (20KiB - image/jpeg)
file #53982:  TF.mat added by luiz (648B - application/octet-stream)
file #53983:  Bode_bug_octave.jpg added by luiz (59KiB - image/jpeg)
file #53984:  bode_bug.m added by luiz (102B - 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 dastew (Posted a comment)
  • -email is unavailable- added by dasergatskov (Updated the item)
  • -email is unavailable- added by nrjank (Updated the item)
  • -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 project members can vote.

     

     

     

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-11-21 nrjank StatusNeed Info Confirmed
    2022-11-21 nrjank StatusNone Need Info
    2022-11-21 dasergatskov Attached File- Added bode_das1.png, #53986
    2022-11-21 nrjank SummaryBode plot problem. Different results between MATLAB and Octave. [octave forge] (control) Bode plot problem. Different results between MATLAB and Octave.
    2022-11-21 luiz Attached File- Added Bode_bug_matlab.jpg, #53981
        Attached File- Added TF.mat, #53982
        Attached File- Added Bode_bug_octave.jpg, #53983
        Attached File- Added bode_bug.m, #53984

    Back to the top


    Powered by Savane 3.9