bugGNU Octave - Bugs: bug #46781, [octave forge] (signal) specgram...

 
 

bug #46781: [octave forge] (signal) specgram flips sign of frequencies when given complex input as row vector

Submitter:  None
Submitted:  Wed 30 Dec 2015 05:43:09 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  mtmiller
Originator Name:  Alastair Harrison Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * other
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 04 Apr 2018 01:13:47 AM UTC, comment #3: 

This is fixed in the signal package repository

https://hg.mtmxr.com/octave-signal/rev/a81804a8a3af

Mike Miller <mtmiller>
Group Member
Fri 01 Jan 2016 04:03:58 AM UTC, comment #2: 

Since the specgram function is obsolete in Matlab, it would also be helpful to have a compatible implementation of the spectrogram function. See bug #45232.

Mike Miller <mtmiller>
Group Member
Wed 30 Dec 2015 06:21:25 PM UTC, comment #1: 

Mike M is the signal pkg maintainer.
the proposed fix looks correct to me.
see line 127 of specgram.m

Doug Stewart <dastew>
Wed 30 Dec 2015 05:43:09 PM UTC, original submission:  

I don't know if Octave's specgram function is intended to allow complex input, but it has some strange behaviour when you do.

Consider the following example. When the input is a complex column vector, we get the expected result. When the input is a row vector, specgram actually shows us the spectrogram of the complex conjugate of the input.


Fs = 44100;

% Generate a complex exponential wave at 8kHz
% Note that we're producing a ROW vector here
t = (0:Fs-1) / Fs;
s = exp(j*2*pi*8000*t);

% Spectrogram has no peak at 8kHz
window = ceil(40*Fs/1000);
step = ceil(20*Fs/1000);
figure(1)
specgram(s, 2^nextpow2(window), Fs, window, window-step);

% But provide the input as a COLUMN vector instead, and we get a peak
% at 8kHz
figure(2)
specgram(s.', 2^nextpow2(window), Fs, window, window-step);


The problem appears to be with this line:

  if columns(x) != 1, x = x'; endif


For complex input, the apostrophe operator both transposes and takes the complex conjugate. A fixed version performs only a transpose:


  if columns(x) != 1, x = x.'; endif


As an aside, I believe that the matlab version of specgram detects complex input and displays both positive and negative frequencies. It would be great if the octave version could do something similar, rather than just chopping off everything above the Nyquist frequency.

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 jwe (Updated the item)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by dastew (Posted a comment)
  • -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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-04-04 mtmiller StatusNone Fixed
        Open/ClosedOpen Closed
    2017-08-13 jwe Summarysignal package: specgram flips sign of frequencies when given complex input as row vector [octave forge] (signal) specgram flips sign of frequencies when given complex input as row vector
    2016-03-29 mtmiller Assigned toNone mtmiller
    2016-01-01 mtmiller Priority5 - Normal 3 - Low
        Item GroupIncorrect Result Matlab Compatibility
        Release4.0.0 other
        Summaryspecgram flips sign of frequencies when given complex input as row vector signal package: specgram flips sign of frequencies when given complex input as row vector

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code