[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #46781] specgram flips sign of frequencies whe
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #46781] specgram flips sign of frequencies when given complex input as row vector |
Date: |
Wed, 30 Dec 2015 17:43:10 +0000 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36 |
URL:
<http://savannah.gnu.org/bugs/?46781>
Summary: specgram flips sign of frequencies when given
complex input as row vector
Project: GNU Octave
Submitted by: None
Submitted on: Wed 30 Dec 2015 05:43:09 PM UTC
Category: Octave Forge Package
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Alastair Harrison
Originator Email: address@hidden
Open/Closed: Open
Discussion Lock: Any
Release: 4.0.0
Operating System: Any
_______________________________________________________
Details:
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.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?46781>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #46781] specgram flips sign of frequencies when given complex input as row vector,
anonymous <=