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?
답변 (3개)
Greg Heath
2013년 1월 13일
0 개 추천
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
2013년 1월 13일
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
2013년 1월 13일
편집: Wayne King
2013년 1월 13일
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
Walter Roberson
2013년 1월 13일
Should that be
plot(f,10*log10(abs(Pyy)))
Wayne King
2013년 1월 13일
Yes, you are absolutely right Walter, thank you! I've corrected the typo.
카테고리
도움말 센터 및 File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!