bugGNU Octave - Bugs: bug #54293, freqz plot differs from MATLAB

 
 

bug #54293: freqz plot differs from MATLAB

Submitter:  Roland Baudin <roland65>
Submitted:  Thu 12 Jul 2018 01:32:32 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 4.2.2 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 12 Jul 2018 01:32:32 PM UTC, original submission:  

Plotting the frequency response of a filter gives different plots in MATLAB and in Octave.

To test:

n = [0 : 127];
h = sinc(0.2*(n-128/2)); % Simple test filter
freqz(h, 1, 128, 'whole', 1); % Frequency response on the whole Nyquist

Plots in MATLAB (tested in versions 2014a and 2017b) and in Octave differs because in this case Octave doubles the number of points used in the FFT, while MATLAB does not. Thus MATLAB uses a 128 points FFT (as requested) while Octave uses a 256 points FFT.

The same happens if we plot the frequency response on half the Nyquist band, like this:
freqz(h, 1, 128, 'half', 1);

I found that commenting out the following lines in freqz.m gives the expected result:

lines 154 to 157

    %~ if (k > n/2 && nargout == 0)
      %~ ## Ensure a causal phase response.
      %~ n *= 2 .^ ceil (log2 (2*k/n));
    %~ endif

lines 168 to 170

      %~ if (plot_output)
        %~ n += 1;
      %~ endif

Roland Baudin <roland65>

 

(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 roland65 (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.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.14-6db8.
    Corresponding source code