Warning: Imaginary parts of complex X and/or Y arguments ignored

I got this problem while applying FFT,
>> f=1803*(0:(2^(n-1)-1))/2^n;
the corresponding matrix 'f' is coming out to be a row vector instead of column. due to this MATLAB warns me 'Warning: Imaginary parts of complex X and/or Y arguments ignored' when I try to plot(f, Pyy(1:2^(n-1))) Pyy is a column vector.
How can I solve this problem and get the plot?

Antworten (3)

Greg Heath
Greg Heath am 13 Jan. 2013

0 Stimmen

That error message warns that you are trying to plot a complex function. Try
whos
to see which complex function you are trying to plot.
Hope this helps.
Greg
f = (1803 * (0:(2^(n-1)-1)) / 2^n) .';
And then f will be a column vector.
You will find, though, that this absolutely will not solve your complex problem.
Hint: you would get exactly the same problem if you were to attempt
plot(1 + 2i)
Wayne King
Wayne King am 13 Jan. 2013
Bearbeitet: Wayne King am 13 Jan. 2013
I'm guessing from your variable, Pyy, that you are trying to plot a spectrum and f is your frequency vector. Then assuming that f and Pyy have the same length.
isequal(length(f),length(Pyy))
should return a 1.
Just do
plot(f,abs(Pyy))
% or usually better if you have a power spectral density estimate
% use dB
plot(f,10*log10(abs(Pyy)))

2 Kommentare

Should that be
plot(f,10*log10(abs(Pyy)))
Yes, you are absolutely right Walter, thank you! I've corrected the typo.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 13 Jan. 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by