Search tips

# Discussion Groups | Comp.DSP | Matlab FFT function does not give the correct result

There are 3 messages in this thread.

You are currently looking at messages 1 to .

Is this discussion worth a thumbs up?

0

# Matlab FFT function does not give the correct result - shakes_ck - 2007-05-16 06:38:00

```Hi,
I am trying to plot my signal(sum of two sines of different frequencies)
in the the frequency domain using FFT function of matlab.
The magnitude plot -> y_mag = real(fft(x,N)
is giving correct result.
But the phase plot -> y_phase = imag(fft(x,N));
is not giving correct result.....
Can someone help me..?

Thanks & Regards,
shakes_ck

_____________________________________
Do you know a company who employs DSP engineers?
Is it already listed at http://dsprelated.com/employers.php ?```

# Re: Matlab FFT function does not give the correct result - Matthieu Puigt - 2007-05-16 06:56:00

```On 16 mai, 12:38, "shakes_ck" <chandrasheka...@patni.com> wrote:
> Hi,

Hi,

>  I am trying to plot my signal(sum of two sines of different frequencies)
> in the the frequency domain using FFT function of matlab.
>  The magnitude plot -> y_mag = real(fft(x,N)
>  is giving correct result.
>  But the phase plot -> y_phase = imag(fft(x,N));
>  is not giving correct result.....
>  Can someone help me..?

You make an error when you resp. compute the magnitude and the phase
of your fft using the real and imaginary part of it.
To obtain the magnitude plot, you should use the modulus of your
Fourier signal: y_mag = abs(ff((x,N));
For the phase plot, you should use the function angle: y_phase angle(fft(x,N));
or the unwrapped phase using the matlab function unwrap: y_phase unwrap(angle(fft(x,N)));

>
> Thanks & Regards,
> shakes_ck
>

Matthieu```

# Re: Matlab FFT function does not give the correct result - Jerry Avins - 2007-05-16 14:42:00

```shakes_ck wrote:
> Hi,
>  I am trying to plot my signal(sum of two sines of different frequencies)
> in the the frequency domain using FFT function of matlab.
>  The magnitude plot -> y_mag = real(fft(x,N)
>  is giving correct result.
>  But the phase plot -> y_phase = imag(fft(x,N));
>  is not giving correct result.....
>  Can someone help me..?

Are you accounting for phase wrapping?

Jerry
--
Engineering is the art of making what you want from things you can get.
Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯```