bugGNU Octave - Bugs: bug #41464, freqz plot differs from matlab

 
 

bug #41464: freqz plot differs from matlab

Submitter:  None
Submitted:  Wed 05 Feb 2014 02:05:14 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  mtmiller
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.8.0
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 13 Feb 2014 05:09:30 AM UTC, comment #8: 

Fixed on the stable branch with this change:

http://hg.savannah.gnu.org/hgweb/octave/rev/694e8f0b3862

This will be part of the 3.8.1 stable point release.

Mike Miller <mtmiller>
Group Member
Tue 11 Feb 2014 01:53:23 PM UTC, comment #7: 

Thanks for confirming. I'm working on some changes to make freqz more visually compatible with Matlab. Should have this fixed later today on the stable branch for the next point release.

Mike Miller <mtmiller>
Group Member
Tue 11 Feb 2014 01:12:16 PM UTC, comment #6: 

When I got the error message, I pasted the freqz line into a session that I was using for work. It must have gotten broken somehow, because it works perfectly in a fresh session. The label does indeed say "Frequency (Hz)". Sorry about the confusion!

Anonymous
Mon 10 Feb 2014 05:25:27 PM UTC, comment #5: 

Maybe you can just go ahead and assume that when the FS argument is given, every calculation and label switches over to using Hertz rather than radians.  That way we can move forward.  This certainly seems like an easy bug to fix.

Rik <rik5>
Group administrator
Mon 10 Feb 2014 02:33:31 PM UTC, comment #4: 

I just get a bunch of errors. Sorry I don't have time to look into it right now, probably it's a minor issue that prevents it from working.

Error using angle (line 6)
Not enough input arguments.

Error in extract_phase>unwrap_phase (line 43)
    phi=unwrap(angle(h));

Error in extract_phase (line 12)
phi = unwrap_phase(h,upn_or_w,iswholerange);

Error in phasez (line 99)
  [phi,w] = extract_phase(h,upn_or_w,iswholerange,upfactor,w,addpoint);

Error in freqz (line 123)
    phi = phasez(b,a,varargin{:});

Anonymous
Mon 10 Feb 2014 02:26:01 PM UTC, comment #3: 

Hmm, are you sure about that? Can you please try the following


freqz([.25, .5, .25], 1, 512, 8000)


The x-axis should go from 0 to 4000.

Mike Miller <mtmiller>
Group Member
Mon 10 Feb 2014 10:26:42 AM UTC, comment #2: 

The optional fs parameter does not affect the axis at all. It still says normalized frequency and the numbers are in range 0..1.

Anonymous
Wed 05 Feb 2014 04:23:07 PM UTC, comment #1: 

Confirmed, judging by the example plot here:

http://www.mathworks.com/help/signal/ref/freqz.html

This is something I've run into before but not gotten around to yet. I'd recommend going even further to make the appearance closer to what users may expect: ditch the legend, labels on x and y axes for both plots.

Can someone with access to Matlab check whether the x axis label says "Normalized Frequency (rad)" vs "Frequency (Hz)" depending on whether the optional "fs" argument is given to freqz?

Mike Miller <mtmiller>
Group Member
Wed 05 Feb 2014 02:05:14 PM UTC, original submission:  

freqz plot has two magnitude plots that zooms in on "interesting areas" in octave while matlab has one plot with the full magnitude.

diff was made against 3.6.4 but the problem remains in latest version

--- C:\Program Files\Octave-3.6.4\share\octave\3.6.4\m\signal\freqz_plot.m 2013-05-28 20:20:18.000000000 +0200
+++ freqz_plot.m 2013-08-13 09:51:33.093494000 +0200
@@ -40,23 +40,13 @@
   phase = unwrap (arg (h));
   maxmag = max (mag);
 
-  subplot (3, 1, 1);
+  subplot (2, 1, 1);
   plot (w, mag);
   grid ("on");
-  legend ("Pass band (dB)");
-  axis ([w(1), w(n), maxmag-3, maxmag], "labely");
+  legend ("Magnitude (dB)");
+  axis ("autoy", "labely");
 
-  subplot (3, 1, 2);
-  plot (w, mag);
-  grid ("on");
-  legend ("Stop band (dB)");
-  if (maxmag - min (mag) > 100)
-    axis ([w(1), w(n), maxmag-100, maxmag], "labely");
-  else
-    axis ("autoy", "labely");
-  endif
-
-  subplot (3, 1, 3);
+  subplot (2, 1, 2);
   plot (w, phase*360/(2*pi));
   grid ("on");
   legend ("Phase (degrees)");

Anonymous

 

(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 rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  •  

    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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-02-13 mtmiller StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2014-02-05 mtmiller Item GroupNone Matlab Compatibility
        StatusNone Confirmed
        Assigned toNone mtmiller

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code