资源简介
研究过程中实现的,分享出来。
是一种多种分析图绘制合一的完整函数并对生成谱进行自动的peaks筛选输出。已经形成自定义函数,放到特定路径下即可直接调用,配有较详细的使用说明
style=1,plot amplitude value spectrumï¼›%style=2,plot power spectrum;%style=3,plot loglog PSD
%style=4,pwelch with segements number
此绘图函数可以输入多种调用参数,如'FrequencyBan','Findpeaks','MinPeakHeight','MinPeakProminence','MinPeakDistance','Threshold','WindowNum','Overlap','Nfft', 'ustar'等参数控制
代码片段和文件信息
function [pkslocspk_wpk_p] = hua_fft(Xfsstylevarargin)
% fs Sampling fequency of signal
% hua_fft(Xfsstylevarargin)
%style=1plot amplitude value spectrum;
%style=2plot power spectrum;
%style=3plot loglog
%style=4pwelch with segements number equals fsplot loglog
%style=other plot both
% ===========varargin======================
%@@‘FrequencyBan‘[f1f2]
%When style=1 varargin input parameters can be used to control the frequency bands
%f1 is start frequency
%f2 is end frequency
%@@‘Findpeaks‘ is used to control the peaks finding
%@@‘MinPeakHeight‘value
% please refer help ‘findpeaks‘ with the same parameter
%@@‘MinPeakProminence‘value
% please refer help ‘findpeaks‘ with the same parameter
%@@‘MinPeakDistance‘value
% please refer help ‘findpeaks‘ with the same parameter
%@@‘Threshold‘value
% please refer help ‘findpeaks‘ with the same parameter
% value = 1e-4 can exclude the flat peak
%@@‘WindowNum‘value
%windows number equal fs as default if no input
%@@‘Overlap‘value
%input overlap from 33%~50% here take 50% overlap as default
%@@‘Nfft‘ value
%input number of DFT points no less than 256
%@@‘ustar‘ value
%input ustar and normalize the PSD to PSD*fs/ustar^2
%http://blog.sina.com.cn/s/blog_574d08530100qu18.html
nfft= 2^nextpow2(length(X));%set step length automatically
%nfft=1024;%set step length manually
%y=X-mean(X);
dtr_X=detrend(X);
y_ft_0=fft(dtr_Xnfft);%DFTget amplitude vaule distribution
y_ft = y_ft_0(1:nfft/2); % throwing away half of X : Nyquist criteria
Amp = 2*abs(y_ft)./nfft; %Amplitude
mx = (abs(y_ft)).^2; %one-sided PSD
y_E=(y_ft.*conj(y_ft))./nfft;%compute the energy spectrum
y_p=y_ft.*conj(y_ft)./nfft; %Power
fn=fs*(0:nfft/2-1)./nfft; %frequency serie
ArgStr = varargin;
switch style
case 1
if nargin==3
Xvar = fn;
Yvar = Amp;
plot(XvarYvar);%use matlab help method plot FFT
ylabel(‘Amplitude‘);xlabel(‘Frequency‘);%title(‘Spectrum of amplitude value‘);
%plot(y_fabs(y_ft(1:nfft/2)));%another method to plot FFT
else
index= find(strcmp(‘FrequencyBan‘ArgStr));
if ~isempty(index)
v_f1=ArgStr{index+1};
v_fn=ArgStr{index+2};
ni=round(v_f1 * nfft/fs+1);
na=round(v_fn * nfft/fs+1);
Xvar = fn(ni:na);
Yvar = abs(y_ft_0(ni:na)*2/nfft);
loglog(XvarYvar);
end
end
if nargin > 3
[arg_strcom4]= SetArgStr(ArgStr);
eval_str= [‘[pkslocspk_wpk_p]=findpeaks(YvarXvar‘arg_strcom4‘‘‘Annotate‘‘‘‘extents‘‘‘‘WidthReference‘‘‘‘halfheight‘‘);‘];
eval(eval_str
相关资源
- Pattern Recognition and Machine Learning(高清
- MATLAB 编程 第二版 Stephen J. Chapman 著
- 均值滤波和FFT频谱分析Matlab代码
- 《MATLAB扩展编程》代码
- HDB3码、AMI码的MATLAB实现
- 3点GPS定位MATLAB仿真
- MATLAB数字信号处理85个实用案例精讲入
- matlab从入门到精通pdf94795
- 欧拉放大论文及matlab代码
- 跳一跳辅助_matlab版本
- 全面详解LTE MATLAB建模、仿真与实现
- MIMO-OFDM无线通信技术及MATLAB实现_孙锴
- MATLAB Programming for Engineers 4th - Chapman
- matlab 各种谱分析对比
- 分数阶chen混沌matlab程序
- 基于粒子群算法的非合作博弈的matl
- MATLAB车流仿真 包括跟驰、延误
- matlab空间桁架计算程序
- 基于MATLAB的图像特征点匹配和筛选
- DMA-TVP-FAVAR
- GPS信号的码捕获matlab代码.7z
- 一维光子晶体MATLAB仿真代码吸收率折
- newmark法源程序
- 传统关联成像、计算鬼成像matlab
- pri传统分选算法
- 摆动滚子推杆盘形凸轮设计
- 医学图像重建作业matlab源码
- Matlab实现混沌系统的控制
- 检测疲劳驾驶
- Matlab锁相环仿真-Phase Locked Loop.rar
评论
共有 条评论