Logarithmic scale using PSD function

조회 수: 6 (최근 30일)
Graeme
Graeme 2011년 3월 3일
I have a problem using the PSD function - basically the output of my code gives the frequency in a linear scale, when i need it in a logarithmic scale. Does anyone know how to alter the PSD/output to give the resulting plot in a logarithmic scale? cl is an array of values. I assume it is something very basic i need to change.
My code is as follows:
Fs = 1/0.005;
h = spectrum.welch;
Hpsd = psd(h,cl,'Fs',Fs);
plot(Hpsd)

채택된 답변

Patrick Kalita
Patrick Kalita 2011년 3월 3일
After creating the plot, set the axes XScale (if you want to replicate a semilogx plot) property to 'log'. For example:
Fs = 1000; t = 0:1/Fs:.296;
x = cos(2*pi*t*200)+randn(size(t));
h = spectrum.welch; % Create a Welch spectral estimator.
Hpsd = psd(h,x,'Fs',Fs); % Calculate the PSD
plot(Hpsd)
set(gca, 'XScale', 'log')
  댓글 수: 1
Graeme
Graeme 2011년 3월 3일
That's it. Thanks very much!

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

the cyclist
the cyclist 2011년 3월 3일
Guessing you need the semilogx, semilogy, or loglog command.

Graeme
Graeme 2011년 3월 3일
I had thought of that, but again that does not work. When i try:
semilogx(Hpsd)
i get the following error:
??? Error using ==> semilogx
Conversion to double from dspdata.psd is not possible.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by