Spectrogram after fft - matlab

I want to ask. I have my data after Fourier transformation in .mat file. I need to get a spectrogram of it.
What function I should to use in Matlab to do it?
spectrogram() function doesn't fit, because it uses signals before Fourier transformation.
Thank you a lot for any help.

Simply put, you can't. Having the Fourier Transform of the entire signal already performed does not allow you to find the spectrogram. Recall that the spectrogram finds the Fourier Transform of local windows whereas what you have found is the Fourier Transform of the entire signal. The spatial locality of the windows is already lost and so you simply can't do what you're asking.

If your data are FFT of entire the signal, you can't plot the spectrogram.
In order to get spectrogram, you have to perform Short-time fourier transform of each frame then plot it to a map.

Related

Masking Audio STFT Matlab

I want to implantation a masking time-frequency audio.
In first, I am using the function : S=spectrogram(x,window,noverlap,nfft) on Matlab, to extract the STFT of the noise+target signal (from WAV file). After that, I am forcing on some coefficients of the STFT(S variable) to be zero with decision of some threshold. But after doing ISTFT I get complex values ( not a real values like I am Expecting - like audio signal).
Can anyone explain where the problem is coming from? And what is the accepted solution to a problem of this kind?
Note:
If I were doing FFT and there doing manipulations on the signal, I would make sure that the signal has properties to be real in time, but how to keep the properties in the STFT plane?
Are you using the MATLAB function spectrogram() or stft()?
I think you should use stft() (because you can use istft() to go back to time domain).
Also whatever processing you do to the time-frequency domain, you should do the same processing to both positive frequencies and negative frequencies.

Plotting Acoustic Waveform - Magnitude on a Linear Frequency Scale

I have an acoustic waveform of a Spanish phoneme and I'd like to compute its magnitude spectrum and plot it in dB magnitude on a linear frequency scale. How would I be able to accomplish this in MATLAB?
Thanks
First a quick heads up: At stackoverflow you are expected to show some of your own efforts to solve the problem and then ask for help.
Now to your question:
You can plot the spectrogram using the "spectrogram" Matlab function.
[s,f,t] = spectrogram(x,window,noverlap,f,fs)
Check the details here: https://www.mathworks.com/help/signal/ref/spectrogram.html
For a speech signal you will want to specify the sampling frequency "fs" (you can get that when you read the file using:
[y,Fs] = audioread(filename)
You will probably want to specify the variables "window" and "noverlap" since speech signals can show distinct properties depending on the dimension of the window (fast phenomena will not be visible on big windows ). A typical values are 20ms windows with 10ms overlap (select the best value by considering your sampling frequency and the nearest 2^n value for fast Fourier calculation).
The window size and overlap are also valid when you calculate spectrum. If you apply FFT to the whole waveform then you will get the "average" spectral information for the sentence. To catch specific phenomena you must use windowing techniques and perform a short-term Fourier analysis.
use sptool
Signal Processing toolbox Show its Document

Wavelet Transform Output in MATLAB

I have a question regarding the output of performing a wavelet transform in MATLAB on an audio signal. I have an audio signal imported into MATLAB using the wavread function. I then perform a one level wavelet transform on the signal using the wavdec function (usually a haar or db4 transform). To transform the signal back to the original audio signal, I then perform an inverse wavelet transform on the signal using the function wavrec. The output of this function brings me back to the original audio signal. However, many data points are slightly off from the original signal (only by about a magnitude of 10^-16 so it is very slight). However, in theory the inverse transform should give me the exact original signal. I am not sure if I am doing something wrong, but is there a reason that after performing a wavelet transform and then performing the inverse that I am not getting an output of exactly the original signal? Thank you very much for any help!
Numbers in a computer are not as perfect as theoretical numbers.
In order to store your data in a finite amount of memory, it's necessary to round it to the nearest representable value. This rounding is very small, but so is the "error" you're seeing.
Go look for the article "What every Computer Scientist should know about Floating-Point Arithmetic", or one of the summaries (The article is great but long, the summaries are shorter but vary in quality).

Frequency representation using discrete wavelet transformation

I am trying to use wavelet transform to represent song in frequency domain using discrete wavelet transform to made decomposition and made the frequency of the singer in place the the song using Matlab
The problem that the dwt and the decomposition mades represent it only in time domain.
How can I represent it in frequency if DWT doesn't represent It what would do?
Thank you
When we say "frequency transform" or talk about "representing frequency" we are usually talking about the Fourier Transform, implemented as the DFT, or discrete Fourier transform. Andre is correct in the comments below when he says that the DWT is also a type of frequency transform; however, wen we say "represent song in frequency domain" it usually means DFT, not DWT.
That being said, I don't recommend the DWT for music and sound analysis because the analysis bands are fixed at one-octave, which is simply too wide to do anything meaningful with. There are other techniques related to wavelets that are more effective for audio, but I don't gather from your question that you are using one of them.
In addition to the DFT, which is usually implemented as the FFT, or fast Fourier transform, you may also want to read about the STFT (short-time Fourier transform).

Strange artefact in my Fourier transform

I have performed an fft (fast fourier transform) on a time series waveform in Matlab, but I seem to have a weird wave actually in the fourier transform plot, although there are spikes this wave looks like something I'd expect to see only in the time domain. Is there any programming reason why this could happen?
The Fourier transform is quite similar to the Inverse Fourier Transform. A spike in one is a wave in the other. Hence, if you have one outlier datapoint in your series, you'll have a wave component in the frequency domain.
A possible programming-related issue could be an uninitialized data point, e.g. providing 1023 datapoints to a 1024-point FFT.
The fft assumes the signal is periodic so you can get some artefacts if the first and last values differ by enough to make that transition look like a step function. You are frequently better off windowing the data to avoid that phenomenon.
Note that the continuous-time Fourier transform of a finite-length signal can have things that look like "spikes" in the frequency domain. See the plots in this post of the continuous-time Fourier transform of a single period of a cosine signal and of ten periods of a cosine signal.
For example, an infinite extent cosine signal has a simple Fourier transform that's a pair of impulses at +/- the cosine frequency. But if you've only got ten periods of the cosine signal, the Fourier transform looks like this:
Steve's currently doing a nice series on Fourier transforms on his blog. He's specifically talking about 2D transforms, but you might find his discussion of windowing helpful.