我用移动平均法做了一下,LZ指点一下,不会传压缩文件,就直接贴出来给你看下
%%%%%%%局部均值分解(LMD)
%%%%%%%将信号分解成AM和FM部分
function [Am_d Fm_d]=lmd_test(x)
%%%%%Am_d幅值部分
%%%%%Fm_d调频部分
%%%%%x原始信号
%%%%%n分解信号的阶数,也可以不设置,默认就是分解到最后一层,此时暂时不设置
n=length(x);
temp_x=x;
%%%%%搜索局部最值
[inmin inmax inzero]=extr(x);
[tmin,tmax,zmin,zmax]=boundary_conditions(inmin,inmax,1:n,x,x,100);%%%%端点延拓
%%%%%做局部均值和包络
[localMaxMin indexTemp]=CombinMaxMin(tmin,tmax,zmin,zmax);
[local_mean local_en index]=LocalMeanEn(localMaxMin,indexTemp);
%%%%%本来应该用移动平均法做局部均值函数,这里还是利用cubic样条函数做的
% interp1.method='cubic';%%%%不同的样条函数在这里换
% LocalMaxEn=interp1(tmax,zmax,1:n,'cubic'); %%%%%上包络
% LocalMinEn=interp1(tmin,zmin,1:n,'cubic'); %%%%%下包络
%把点用直线连起来
m=interp1(index,local_mean,1:n);
a=interp1(index,local_en,1:n);
% 平滑曲线
LocalMeanFun=smooth(m);
LocalEnFun=smooth(a);
LocalMeanFun=LocalMeanFun';
LocalEnFun=LocalEnFun';
% LocalMeanFun=(LocalMaxEn+LocalMinEn)/2;
% LocalEnFun=(abs(LocalMaxEn-LocalMinEn))/2;
% LocalMeanFun=interp1(index,local_mean,1:n,interpl.method);
% LocalEnFun=interp1(index,local_en,1:n,interpl.method);
Am_d=LocalEnFun;
hhhtt_tt=x-LocalMeanFun;
ssstt_tt=hhhtt_tt./LocalEnFun;
%%%%%判断ssstt_tt是不是纯调频信号
flag=1;
Delta_delta=1e-8;
temp_ss=find(ssstt_tt>1+Delta_delta | ssstt_tt<-1-Delta_delta);
[LineSize ColumnSize]=size(temp_ss);
flag=ColumnSize;
%%%CounterSize=1;
while flag %%%& CounterSize<100
x=ssstt_tt;
%%%%%搜索局部最值
[inmin inmax inzero]=extr(x);
[tmin,tmax,zmin,zmax]=boundary_conditions(inmin,inmax,1:n,x,x,4);%%%%端点延拓
%%%%%做局部均值和包络
% LocalMaxEn=interp1(tmax,zmax,1:n,'cubic'); %%%%%上包络
% LocalMinEn=interp1(tmin,zmin,1:n,'cubic'); %%%%%下包络
[localMaxMin indexTemp]=CombinMaxMin(tmin,tmax,zmin,zmax);
[local_mean local_en index]=LocalMeanEn(localMaxMin,indexTemp);
%把点用直线连起来
m=interp1(index,local_mean,1:n);
a=interp1(index,local_en,1:n);
%平滑曲线
LocalMeanFun=smooth(m);
LocalEnFun=smooth(a);
LocalMeanFun=LocalMeanFun';
LocalEnFun=LocalEnFun';
% LocalMeanFun=(LocalMaxEn+LocalMinEn)/2;
% LocalEnFun=(abs(LocalMaxEn-LocalMinEn))/2;
% [localMaxMin indexTemp]=CombinMaxMin(tmin,tmax,zmin,zmax);
% [local_mean local_en index]=LocalMeanEn(localMaxMin,indexTemp);
%%%%%本来应该用移动平均法做局部均值函数,这里还是利用cubic样条函数做的
% LocalMeanFun=interp1(index,local_mean,1:n,interpl.method);
% LocalEnFun=interp1(index,local_en,1:n,interpl.method);
Am_d=Am_d.*LocalEnFun;
hhhtt_tt=x-LocalMeanFun;
ssstt_tt=hhhtt_tt./LocalEnFun;
temp_ss=find(ssstt_tt>1+Delta_delta | ssstt_tt<-1-Delta_delta);
[LineSize ColumnSize]=size(temp_ss);
flag=ColumnSize;
%%%CounterSize=CounterSize+1;
end
Fm_d=ssstt_tt; |