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

 
 

bug #54293: freqz plot differs from MATLAB

Submitted by:  Roland Baudin <roland65>
Submitted on:  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

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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 (2k/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)
  •  

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

    Only project members can vote.

     

     

     

    No changes have been made to this item

    Back to the top


    Powered by Savane 3.3