Ⅰ matlab编的有关EMD去噪的程序,处理的是核磁共振测井信号,急求
function imf = emd(x,n);%%最好把函数名改为emd1之类的,以免和Grilling的emd冲突
%%n为你想得到的IMF的个数
c = x('; % of the input signal (as a row vector)
N = length(x);-
% loop to decompose the input signal into n successive IMFs
imf = []; % Matrix which will contain the successive IMF, and the resiefor t=1:n
% loop on successive IMFs
%-------------------------------------------------------------------------
% inner loop to find each imf
h = c; % at the beginning of the sifting process, h is the signal
SD = 1; % Standard deviation which will be used to stop the sifting process
while SD > 0.3 % while the standard deviation is higher than 0.3 (typical value) %%筛选停止准则
% find local max/min points
d = diff(h); % approximate derivative %%求各点导数
maxmin = []; % to store the optima (min and max without distinction so far)
for i=1:N-2
if d(i)==0 % we are on a zero %%导数为0的点,即”驻点“,但驻点不一定都是极值点,如y=x^3的x=0处
if sign(d(i-1))~=sign(d(i+1)) % it is a maximum %%如果驻点两侧的导数异号(如一边正,一边负),那么该点为极值点
maxmin = [maxmin, i]; %%找到极值点在信号中的坐标(不分极大值和极小值点)
end
elseif sign(d(i))~=sign(d(i+1)) % we are straddling a zero so%%如y=|x|在x=0处是极值点,但该点倒数不存在,所以不能用上面的判
断方法
maxmin = [maxmin, i+1]; % define zero as at i+1 (not i) %%这里提供了另一类极值点的判断方法
end
end
if size(maxmin,2) < 2 % then it is the resie %%判断信号是不是已经符合残余分量定义
break
end
% divide maxmin into maxes and mins %% 分离极大值点和极小值点
if maxmin(1)>maxmin(2) % first one is a max not a min
maxes = maxmin(1:2:length(maxmin));
mins = maxmin(2:2:length(maxmin));
else % is the other way around
maxes = maxmin(2:2:length(maxmin));
mins = maxmin(1:2:length(maxmin));
end % make endpoints both maxes and mins
maxes = [1 maxes N];
mins = [1 mins N];
%------------------------------------------------------------------------- % spline interpolate to get max and min envelopes; form imf
maxenv = spline(maxes,h(maxes),1:N); %%用样条函数插值拟合所有的极大值点
minenv = spline(mins, h(mins),1:N); %%用样条函数插值拟合所有的极小值点
m = (maxenv + minenv)/2; % mean of max and min enveloppes %%求上下包络的均值
prevh = h; % of the previous value of h before modifying it %%h为分解前的信号
h = h - m; % substract mean to h %% 减去包络均值
% calculate standard deviation
eps = 0.0000001; % to avoid zero values
SD = sum ( ((prevh - h).^2) ./ (prevh.^2 + eps) ); %% 计算停止准则
end
imf = [imf; h]; % store the extracted IMF in the matrix imf
% if size(maxmin,2)<2, then h is the resie
% stop criterion of the algo. if we reach the end before n
if size(maxmin,2) < 2
break
end
c = c - h; % substract the extracted IMF from the signal
end
return
Ⅱ matlab装上EMD工具箱后怎么调用emd函数啊
下载的工具箱中的emd.m文件里的注释有详细的用法介绍。
工具箱的安装
运行install_emd.m文件可以实现此工具箱的安装,uninstall_emd.m实现卸载。
安装中的问题
但是安装的时候,如果使用的是VS的编译器(mbuild –setup、mex –setup设置),会报找不到complex.h的问题(用Linux下的Matlab不会出错),从而使cemdc2_fix.c等文件编译失败,这几个文件是为了快速实现计算EMD而用c编写的,所以即使编译失败,也不影响直接使用emd.m实现EMD功能。如果想编译成功,可如下修改:(摘自http://www.chinavib.com/thread-79866-1-1.html)
G. Rilling 07年3月份的程序,运行作者的install_emd.m,出现找不到complex.h的问题,以下是个人的理解和解决过程:(个人的运行环境为matlab6.5)
complex.h的问题
产生原因:采用matlab的C编译函数mex时,定义了C99_OK的宏(EMDS/make_emdc.m (28行)),利用的是ANSI C99标准如果个人的电脑中没有相关的支持,就会出现这个问题。
解决方法:EMDS/make_emdc.m中第28行中mex(’-DC99_OK‘,args(:))语句中的 '-DC99_OK' 即可。
注意:
改完之后,运行install_emd,会出现M_PI没有定义的问题,缺少了常数PI的宏定义,导致一些.c文件编译失败。
产生原因:去掉C99_OK之后,程序中使用的是作者提供的 emd_complex.h和emd_complex.c两个文件来支持复数运算,这两个文件中,并没有定义M_PI这个宏。
解决方法:M_PI这个宏,只在两个文件中(clocal_mean.c和clocal_mean2.c)使用,个人的解决方法是,在相应的头文件(clocal_mean.h和clocal_mean2.h)中加入M_PI的宏定义即可。
在两个.h文件中分别加入一下语句:
#define CLOCAL_MEAN_H
#ifndef M_PI
#define M_PI 3.1415926
#endif
安装完成后,编译输出的.dll文件会出现,重复后缀名的问题,及 xxx.dll 变成了 xxx.dll.dll自己去掉多余的.dll即可
最后,关于版本问题:作者推荐使用7.1+版本,但只是针对个别的函数有影响,主要是作者提供的例子程序,无法在matlab6.5环境中运行,算法的主要功能函数并不受影响。
Ⅲ matlab emd工具箱使用
其实用起来也很简单的,举个例子:
clearall;
clf;
t=0:0.1:4*pi;
%构造一个信号
x=10.*sin(t)+5.*cos(2.*t);
%加点内噪容声
noise=normrnd(0,1,1,length(x));
y=x+noise;
%emd分解
imf=emd(x);
[mn]=size(imf);
emd_visu(x,t,imf);
Ⅳ matlab有emd函数吗
没有的,但是可以用matlab的时频工具箱,工具箱下载地址:http://tftb.nongnu.org/
matlab的工具箱的安装步骤:
1.解压专下载的文件包,属将tft/mfile复制到matlab的toolbox文件夹下
2.建立搜索路径,matlab->file->Set Path->Add Folder
->选择mfile文件夹复制到matlab的toolbox的路径->save->close
3.测试是否建立搜索路径成功,在matlab命令窗口打入:which fmsin
返回的结果是你放mfile的正确路径说明建立搜索路径成功,就完成了安装工具包的工作。
此时EMD的准备工作就完了。
Ⅳ MATLAB中如何调用EMD工具箱
1、首先下载emd工具箱,50楼网址里面可以下。下载后解压放在matlab的work工作路径下package_emd文件夹。
2、打开matlab,选版择File- Set Path- Add with Subfolders-你刚才权下载的工具箱(package_emd)点进去- Save- Close。
3、此时选择work下package_emd文件夹作为工作路径,即是D:\matlabR2006b\work\package_emd。
4、在Command Window里面输入mex -setup回车,问是否选择已有的编译器你选y回车,再问选择哪个编译器,你可以选择C++的那个选择相应的编号(如 2)回车,然后让你核对是否选择对了编译器等等,你输入y回车。。。就安装成功了了
Ⅵ 有关EMD分解matlab程序
一般的的查询可在matlab里的帮助界面进行搜索,点击帮助。
打开帮助页回面,左侧检索答栏进行检索需要查询的语句,然后即可查看右侧查询结果。
或者在主界面,输入help 空格+你要查询的内容,进行查询。下次你可以尝试一下。
一般程序都会有不懂得语句,或没用过的,可以在刚刚说过的帮助页面进行查询,看如何使用,输入参量什么意义,程序输出结果是什么。
你这个描述太过于简略了,我只能给出这样的答案了,一般可以都给一点程序,也许会有对答题人帮助。
不过你这个程序的确有点复杂,不根据前后逻辑,和主程序和目的是很难解答的。
你可以看看主程序,再查查帮助。
希望对你有所帮助。谢谢。