⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 psdtukey.m

📁 很多matlab的源代码
💻 M
字号:
function ps = psdtukey(x,m)
%PSDTUKEY Spectrum estimation using Bartlett windowed autocorrelation
%	PSD=psdtukey(x,m): x=data sequence, 
%	m=Bartlett window length for autocorrelation (Def: m=0.1*length(x))
%	Plots PSD vs difital frequency F if no output arguments given
%	NOTE: PSD is normalized: sum(x.*x)/length(x) = sum(PSD)/length(PSD)
%
%	PSDTUKEY with no arguments invokes the following example
%
%	PSD of 512 samples of a chirp signal between F=0.2 and F=0.4
%	>> xc=chirp([0.2 0.4],512); psdtukey(xc);


% ADSP Toolbox: Version 2.0 
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998


if nargin==0,help psdtukey,disp('Strike a key to see results of the example')
pause,xc=chirp([0.2 0.4],512);psdtukey(xc);return,end

l=length(x);if nargin<2,m=fix(l/10);end
[mm,nn]=size(x);if nn==1,x=x.';end
if rem(m,2)==1,m=m+1;end
y=[x zeros(1,l)];yf=fft(y);g=yf.*conj(yf);cy=real(ifft(g))/l;
w=window('bart',m+1);wac(1:m/2+1)=cy(1:m/2+1).*w(m/2+1:m+1);
wac=[fliplr(wac(2:m/2+1)) wac(1:m/2)];
%ps=abs(fft(wac,2*l)); %%OLD
ps=abs(fft(wac));%NEW: FFT OF M-SAMPLE ACF
if nargout==0
plot((-m/2:m/2-1)/m,fftshift(ps)),
%axis([-1/2 1/2 0 inf]) %%NEW
title('PSD =  vs digital Frequency F'),
%subplot
end
if nn==1,ps=ps.';end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -