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

📄 log_psd.m

📁 谢谢站长!谢谢给我这次下载的机会!非常感谢!现在上传一些我仿真的多普勒功率普的程序
💻 M
字号:
%file:log_psd.m
% this function takes n time domain samples(real or complex)
% and finds the psd by taking (fft/n)^2
% the two sided spectrum is produced by shifting the psd.
% the array freq provides the appropriate frequency values for plotting purposes
% by taking 10*log10(psd/max(psd)) the psd is normalized
% values below -60dB are set equal to -60dB

%n must be an even number,preferably a power of 2
function [logpsd,freq,ptotal,pmax]=log_psd(x,n,ts)
% n=1024;
y=zeros(1,n);                           %initialize y vector
h=waitbar(0,'for loop in psd calculation');
for k=1:n
    freq(k)=(k-1-(n/2))/(n*ts);
    y(k)=x(k)*((-1.0)^k);
    waitbar(k/n)
end;
v=fft(y)/n;
psd=abs(v).^2;
pmax=max(psd);
ptotal=sum(psd);
logpsd=10*log10(psd/pmax);

%truncate negative values at -60dB
for k=1:n
    if(logpsd(k)<-60.0)
        logpsd(k)=-60.0;
    end
end
close(h)
%end of function file

⌨️ 快捷键说明

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