资源简介
研究过程中实现的,分享出来。
是一种多种分析图绘制合一的完整函数并对生成谱进行自动的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
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论