Warning: Imaginary parts of complex X and/or Y arguments ignored
Show older comments
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?
Answers (3)
Greg Heath
on 13 Jan 2013
0 votes
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
Walter Roberson
on 13 Jan 2013
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
on 13 Jan 2013
Edited: Wayne King
on 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 Comments
Walter Roberson
on 13 Jan 2013
Should that be
plot(f,10*log10(abs(Pyy)))
Wayne King
on 13 Jan 2013
Yes, you are absolutely right Walter, thank you! I've corrected the typo.
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!