time<->frequency conversions and displaying in matlab

Status
Not open for further replies.

BMWE

Member level 2
Joined
Apr 4, 2005
Messages
51
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,585
time frequency matlab

hi

i know that to convert to frequency domain i need to do the fft and ifft to convert to time domain.
but how to display it right in matlab? suppose that i generate signal in time/frequency domain and need to convert to frequency/time domain.


----------------
Now playing: Freddie Mercury + Monserrat Caballé - Barcelona
via FoxyTunes
 

matlab frequency time domain plot

You can try this:

(let's say that your signal 'x' is random gaussian noise with zero mean and unit variance - you can use whatever you want - and your FFT size is NFFT)

x = randn(1,100);
NFFT = 1024;
X = fft(x, NFFT);
plot(-NFFT/2:NFFT/2 - 1, fftshift(abs(X)))

X is usually a complex signal, so we use its absolute value to plot it (You can plot the real or imaginary part seperately).
The fftshift function is used to shift the spectrum around DC frequency.

To get back your time domain signal, just use:

xx = ifft(X, NFFT);

I hope that it helps...
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…