Warning: Imaginary parts of complex X and/or Y arguments ignored
Mostrar comentarios más antiguos
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?
Respuestas (3)
Greg Heath
el 13 de En. de 2013
0 votos
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
el 13 de En. de 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
el 13 de En. de 2013
Editada: Wayne King
el 13 de En. de 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 comentarios
Walter Roberson
el 13 de En. de 2013
Should that be
plot(f,10*log10(abs(Pyy)))
Wayne King
el 13 de En. de 2013
Yes, you are absolutely right Walter, thank you! I've corrected the typo.
Categorías
Más información sobre Fourier Analysis and Filtering en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!