0
$\begingroup$

I have the following signal:

enter image description here

I'm trying to compute a Spectrogram algorithm, but, don't think I'm doing it right..

I have computed the following:

1) STFT (size 256 with an overlap of 128) 2) Computed the logs using: '10 * log10(sqrt(re * re + im + im)

This is the result that I get:

enter image description here

But when I use pylab in Python (for the same signal): x = pl.specgram(signal)

I get the following result:

enter image description here

Using the matplotlib I get the following:

enter image description here

Obviously, these are very different results.. I don't know why I'm getting these, I'm new to signal processing and spectrograms. Hope someone can help

EDIT:

This is the result I have when doing imshow in python:

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ How can you can call figure no. 2 a spectrogram when there is a time and amplitude on axis? To me it looks like a squared signal in log scale. I have the feeling that you first should read about: STFT. You must split your signals into frames, calculate DFT for each of them (this will give you a spectrum) and in the result you will obtain a matrix - MxN (M - number of frames, N - number of frequency bins). From that point you can play further. Some basic reference for python: scipy STFT $\endgroup$
    – jojeck
    Mar 25, 2014 at 14:53
  • $\begingroup$ "Using the matplotlib I get the following:" You're plotting a 2-dimensional array, so it interprets it as multiple 1-dimensional plots. You need to use imshow or pcolor or something. What is the arrayname.shape of your array? Show your code. $\endgroup$
    – endolith
    Mar 25, 2014 at 15:18

2 Answers 2

1
$\begingroup$

This appears to be just a matter of projection. Try "imagesc" in matlab.

$\endgroup$
1
  • $\begingroup$ Please see my updated post. Why am I getting such a result? :( $\endgroup$
    – Phorce
    Jan 5, 2014 at 1:32
1
$\begingroup$

It seems you obtain one value for each time considered. You should be taking the fourier transform of the signal with a window centered on the point t1, this gives you a spectrum (a vector, not a scalar), move to t2, repeat that gives a second spectrum and so on. Spectrogram will be a collection of spectra indexed by time, it is a time/frequency representation, your result is 1D not 2D

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.