필터 지우기
필터 지우기

Power spectral density plot correction

조회 수: 7 (최근 30일)
Petr Machac
Petr Machac 2020년 3월 17일
답변: Sriram Tadavarty 2020년 3월 17일
Hello, I want to make a power spectral density estimate using periodogram and welch method and I need to plot them in one graph,
I have this simple script (my data are different I just want this code to be simple):
n = 0:319;
x = cos(pi/4*n) + randn(size(n));
pwelch(x)
hold on
periodogram(x,rectwin(length(x)),length(x))
The result is what it should be, but the graphs are in the same color, so it is unrecognizable what was done using pwelch and what using periodogram, how can I set different colours of the lines?
Thank you very much

채택된 답변

Sriram Tadavarty
Sriram Tadavarty 2020년 3월 17일
Hi Petr,
By default, you cannot change the color of output from the functions. However, you can do slight modification to the code to make the clear distinction. Here is the code, update the periodogram function with outputs and plot it. However, this can be applied even for pwelch.
[pxx,w] = periodogram(x,rectwin(length(x)),length(x));
plot(w,10*log10(pxx),'r')
Hope this helps.
Regards,
Sriram

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by