求基于matlab的EMD代码,急!
ilovematlab论坛上可以免费下载,都可以运行
你的EMD是% G. Rilling,的那个吗?
len = size(imf,1);
for k = 1:len
len1 = length(imf(k,:));
b(k) = sum(imf(k,:).*imf(k,:))/len1;% 时域均方值,能量
amp(k,:) = abs(imf(k,:));
b(k) = sqrt(b(k));
th = angle(hilbert(imf(k,:)));%Hilbert变换的相位
d(k,:) = diff(th)/Ts/(2*pi);%求导,得到频率:f = (1/2*pi)*d(th)/dt
end
你的频率公式用得有点问题,求出来不应是归一化频率
>>edit svmclassify
>>edit svmpredict
function [svm_struct, svIndex] = svmtrain(training, groupnames, varargin)
%SVMTRAIN trains a support vector machine classifier
%
% SVMStruct = SVMTRAIN(TRAINING,GROUP) trains a support vector machine
% classifier using data TRAINING taken from two groups given by GROUP.
% SVMStruct contains information about the trained classifier that is
% used by SVMCLASSIFY for classification. GROUP is a column vector of
% values of the same length as TRAINING that defines two groups. Each
% element of GROUP specifies the group the corresponding row of TRAINING
% belongs to. GROUP can be a numeric vector, a string array, or a cell
% array of strings. SVMTRAIN treats NaNs or empty strings in GROUP as
% missing values and ignores the corresponding rows of TRAINING.
%
% SVMTRAIN(...,'KERNEL_FUNCTION',KFUN) allows you to specify the kernel
% function KFUN used to map the training data into kernel space. The
% default kernel function is the dot product. KFUN can be one of the
% following strings or a function handle:
%
% 'linear' Linear kernel or dot product
% 'quadratic' Quadratic kernel
% 'polynomial' Polynomial kernel (default order 3)
% 'rbf' Gaussian Radial Basis Function kernel
% 'mlp' Multilayer Perceptron kernel (default scale 1)
% function A kernel function specified using @,
% for example @KFUN, or an anonymous function
%
% A kernel function must be of the form
%
% function K = KFUN(U, V)
%
% The returned value, K, is a matrix of size M-by-N, where U and V have M
% and N rows respectively. If KFUN is parameterized, you can use
% anonymous functions to capture the problem-dependent parameters. For
% example, suppose that your kernel function is
%
% function k = kfun(u,v,p1,p2)
% k = tanh(p1*(u*v')+p2);
%
% You can set values for p1 and p2 and then use an anonymous function:
% @(u,v) kfun(u,v,p1,p2).
%
% SVMTRAIN(...,'POLYORDER',ORDER) allows you to specify the order of a
% polynomial kernel. The default order is 3.
%
% SVMTRAIN(...,'MLP_PARAMS',[P1 P2]) allows you to specify the
% parameters of the Multilayer Perceptron (mlp) kernel. The mlp kernel
% requires two parameters, P1 and P2, where K = tanh(P1*U*V' + P2) and P1
% > 0 and P2 < 0. Default values are P1 = 1 and P2 = -1.
%
% SVMTRAIN(...,'METHOD',METHOD) allows you to specify the method used
% to find the separating hyperplane. Options are
%
% 'QP' Use quadratic programming (requires the Optimization Toolbox)
% 'LS' Use least-squares method
%
% If you have the Optimization Toolbox, then the QP method is the default
% method. If not, the only available method is LS.
%
% SVMTRAIN(...,'QUADPROG_OPTS',OPTIONS) allows you to pass an OPTIONS
% structure created using OPTIMSET to the QUADPROG function when using
% the 'QP' method. See help optimset for more details.
%
% SVMTRAIN(...,'SHOWPLOT',true), when used with two-dimensional data,
% creates a plot of the grouped data and plots the separating line for
% the classifier.
%
% Example:
% % Load the data and select features for classification
% load fisheriris
% data = [meas(:,1), meas(:,2)];
% % Extract the Setosa class
% groups = ismember(species,'setosa');
% % Randomly select training and test sets
% [train, test] = crossvalind('holdOut',groups);
% cp = classperf(groups);
% % Use a linear support vector machine classifier
% svmStruct = svmtrain(data(train,:),groups(train),'showplot',true);
% classes = svmclassify(svmStruct,data(test,:),'showplot',true);
% % See how well the classifier performed
% classperf(cp,classes,test);
% cp.CorrectRate
%
% See also CLASSIFY, KNNCLASSIFY, QUADPROG, SVMCLASSIFY.
% Copyright 2004 The MathWorks, Inc.
% $Revision: 1.1.12.1 $ $Date: 2004/12/24 20:43:35 $
% References:
% [1] Kecman, V, Learning and Soft Computing,
% MIT Press, Cambridge, MA. 2001.
% [2] Suykens, J.A.K., Van Gestel, T., De Brabanter, J., De Moor, B.,
% Vandewalle, J., Least Squares Support Vector Machines,
% World Scientific, Singapore, 2002.
% [3] Scholkopf, B., Smola, A.J., Learning with Kernels,
% MIT Press, Cambridge, MA. 2002.
%
% SVMTRAIN(...,'KFUNARGS',ARGS) allows you to pass additional
% arguments to kernel functions.
% set defaults
plotflag = false;
qp_opts = [];
kfunargs = {};
setPoly = false; usePoly = false;
setMLP = false; useMLP = false;
if ~isempty(which('quadprog'))
useQuadprog = true;
else
useQuadprog = false;
end
% set default kernel function
kfun = @linear_kernel;
% check inputs
if nargin < 2
error(nargchk(2,Inf,nargin))
end
numoptargs = nargin -2;
optargs = varargin;
% grp2idx sorts a numeric grouping var ascending, and a string grouping
% var by order of first occurrence
[g,groupString] = grp2idx(groupnames);
% check group is a vector -- though char input is special...
if ~isvector(groupnames) && ~ischar(groupnames)
error('Bioinfo:svmtrain:GroupNotVector',...
'Group must be a vector.');
end
% make sure that the data is correctly oriented.
if size(groupnames,1) == 1
groupnames = groupnames';
end
% make sure data is the right size
n = length(groupnames);
if size(training,1) ~= n
if size(training,2) == n
training = training';
else
error('Bioinfo:svmtrain:DataGroupSizeMismatch',...
'GROUP and TRAINING must have the same number of rows.')
end
end
% NaNs are treated as unknown classes and are removed from the training
% data
nans = find(isnan(g));
if length(nans) > 0
training(nans,:) = [];
g(nans) = [];
end
ngroups = length(groupString);
if ngroups > 2
error('Bioinfo:svmtrain:TooManyGroups',...
'SVMTRAIN only supports classification into two groups.\nGROUP contains %d different groups.',ngroups)
end
% convert to 1, -1.
g = 1 - (2* (g-1));
% handle optional arguments
if numoptargs >= 1
if rem(numoptargs,2)== 1
error('Bioinfo:svmtrain:IncorrectNumberOfArguments',...
'Incorrect number of arguments to %s.',mfilename);
end
okargs = {'kernel_function','method','showplot','kfunargs','quadprog_opts','polyorder','mlp_params'};
for j=1:2:numoptargs
pname = optargs{j};
pval = optargs{j+1};
k = strmatch(lower(pname), okargs);%#ok
if isempty(k)
error('Bioinfo:svmtrain:UnknownParameterName',...
'Unknown parameter name: %s.',pname);
elseif length(k)>1
error('Bioinfo:svmtrain:AmbiguousParameterName',...
'Ambiguous parameter name: %s.',pname);
else
switch(k)
case 1 % kernel_function
if ischar(pval)
okfuns = {'linear','quadratic',...
'radial','rbf','polynomial','mlp'};
funNum = strmatch(lower(pval), okfuns);%#ok
if isempty(funNum)
funNum = 0;
end
switch funNum %maybe make this less strict in the future
case 1
kfun = @linear_kernel;
case 2
kfun = @quadratic_kernel;
case {3,4}
kfun = @rbf_kernel;
case 5
kfun = @poly_kernel;
usePoly = true;
case 6
kfun = @mlp_kernel;
useMLP = true;
otherwise
error('Bioinfo:svmtrain:UnknownKernelFunction',...
'Unknown Kernel Function %s.',kfun);
end
elseif isa (pval, 'function_handle')
kfun = pval;
else
error('Bioinfo:svmtrain:BadKernelFunction',...
'The kernel function input does not appear to be a function handle\nor valid function name.')
end
case 2 % method
if strncmpi(pval,'qp',2)
useQuadprog = true;
if isempty(which('quadprog'))
warning('Bioinfo:svmtrain:NoOptim',...
'The Optimization Toolbox is required to use the quadratic programming method.')
useQuadprog = false;
end
elseif strncmpi(pval,'ls',2)
useQuadprog = false;
else
error('Bioinfo:svmtrain:UnknownMethod',...
'Unknown method option %s. Valid methods are ''QP'' and ''LS''',pval);
end
case 3 % display
if pval ~= 0
if size(training,2) == 2
plotflag = true;
else
warning('Bioinfo:svmtrain:OnlyPlot2D',...
'The display option can only plot 2D training data.')
end
end
case 4 % kfunargs
if iscell(pval)
kfunargs = pval;
else
kfunargs = {pval};
end
case 5 % quadprog_opts
if isstruct(pval)
qp_opts = pval;
elseif iscell(pval)
qp_opts = optimset(pval{:});
else
error('Bioinfo:svmtrain:BadQuadprogOpts',...
'QUADPROG_OPTS must be an opts structure.');
end
case 6 % polyorder
if ~isscalar(pval) || ~isnumeric(pval)
error('Bioinfo:svmtrain:BadPolyOrder',...
'POLYORDER must be a scalar value.');
end
if pval ~=floor(pval) || pval < 1
error('Bioinfo:svmtrain:PolyOrderNotInt',...
'The order of the polynomial kernel must be a positive integer.')
end
kfunargs = {pval};
setPoly = true;
case 7 % mlpparams
if numel(pval)~=2
error('Bioinfo:svmtrain:BadMLPParams',...
'MLP_PARAMS must be a two element array.');
end
if ~isscalar(pval(1)) || ~isscalar(pval(2))
error('Bioinfo:svmtrain:MLPParamsNotScalar',...
'The parameters of the multi-layer perceptron kernel must be scalar.');
end
kfunargs = {pval(1),pval(2)};
setMLP = true;
end
end
end
end
if setPoly && ~usePoly
warning('Bioinfo:svmtrain:PolyOrderNotPolyKernel',...
'You specified a polynomial order but not a polynomial kernel');
end
if setMLP && ~useMLP
warning('Bioinfo:svmtrain:MLPParamNotMLPKernel',...
'You specified MLP parameters but not an MLP kernel');
end
% plot the data if requested
if plotflag
[hAxis,hLines] = svmplotdata(training,g);
legend(hLines,cellstr(groupString));
end
% calculate kernel function
try
kx = feval(kfun,training,training,kfunargs{:});
% ensure function is symmetric
kx = (kx+kx')/2;
catch
error('Bioinfo:svmtrain:UnknownKernelFunction',...
'Error calculating the kernel function:\n%s\n', lasterr);
end
% create Hessian
% add small constant eye to force stability
H =((g*g').*kx) + sqrt(eps(class(training)))*eye(n);
if useQuadprog
% The large scale solver cannot handle this type of problem, so turn it
% off.
qp_opts = optimset(qp_opts,'LargeScale','Off');
% X=QUADPROG(H,f,A,b,Aeq,beq,LB,UB,X0,opts)
alpha = quadprog(H,-ones(n,1),[],[],...
g',0,zeros(n,1),inf *ones(n,1),zeros(n,1),qp_opts);
% The support vectors are the non-zeros of alpha
svIndex = find(alpha > sqrt(eps));
sv = training(svIndex,:);
% calculate the parameters of the separating line from the support
% vectors.
alphaHat = g(svIndex).*alpha(svIndex);
% Calculate the bias by applying the indicator function to the support
% vector with largest alpha.
[maxAlpha,maxPos] = max(alpha); %#ok
bias = g(maxPos) - sum(alphaHat.*kx(svIndex,maxPos));
% an alternative method is to average the values over all support vectors
% bias = mean(g(sv)' - sum(alphaHat(:,ones(1,numSVs)).*kx(sv,sv)));
% An alternative way to calculate support vectors is to look for zeros of
% the Lagrangians (fifth output from QUADPROG).
%
% [alpha,fval,output,exitflag,t] = quadprog(H,-ones(n,1),[],[],...
% g',0,zeros(n,1),inf *ones(n,1),zeros(n,1),opts);
%
% sv = t.lower < sqrt(eps) & t.upper < sqrt(eps);
else % Least-Squares
% now build up compound matrix for solver
A = [0 g';g,H];
b = [0;ones(size(g))];
x = A\b;
% calculate the parameters of the separating line from the support
% vectors.
sv = training;
bias = x(1);
alphaHat = g.*x(2:end);
end
svm_struct.SupportVectors = sv;
svm_struct.Alpha = alphaHat;
svm_struct.Bias = bias;
svm_struct.KernelFunction = kfun;
svm_struct.KernelFunctionArgs = kfunargs;
svm_struct.GroupNames = groupnames;
svm_struct.FigureHandles = [];
if plotflag
hSV = svmplotsvs(hAxis,svm_struct);
svm_struct.FigureHandles = {hAxis,hLines,hSV};
end
你的emd是%
g.
rilling,的那个吗?
len
=
size(imf,1);
for
k
=
1:len
len1
=
length(imf(k,:));
b(k)
=
sum(imf(k,:).*imf(k,:))/len1;%
时域均方值,能量
amp(k,:)
=
abs(imf(k,:));
b(k)
=
sqrt(b(k));
th
=
angle(hilbert(imf(k,:)));%hilbert变换的相位
d(k,:)
=
diff(th)/ts/(2*pi);%求导,得到频率:f
=
(1/2*pi)*d(th)/dt
end
你的频率公式用得有点问题,求出来不应是归一化频率
能否把代码也发我一份,我想把这个方法用在地球化学方面
我邮箱258275248@qq.com
求楼主解答 邮箱362382447@qq.com 感谢万分
哥们 我现在在做这课程设计 能不能把你的给我看看一下了 727674595@qq.com 谢谢了
基于MATLAB,对彩色图像进行中值滤波
1、阅读图片,以pout.tif为例,加上盐和胡椒噪音。2、分别建立3×3高斯滤波器模板和平均滤波器模板,并对经过噪声添加的图像进行滤波。显示原始图像,噪声图像和由高斯和平均模板过滤的图像。3、图片结果如图所示。可以看出,平均模板滤波后的噪声非常明显。高斯模板滤波的噪声影响相对较小。4、之后我们...
什么是图像识别?图像识别的方法。(基于matlab的)
什么是图像识别?这个问题如果乍一问出,很多人可能都会愣一下,但一细想,便能说出很多很多的应用场景,想什么二维码啊,人脸识别啊,网站识图啊之类的。那么又有多少人去真正了解过这项技术呢?今天就让我给您简单介绍一下吧!计算机识别一张图时会将其转化为数字,通过「训练」计算机可以知道这些数字...
m基于LTE的通信链路matlab仿真,上行为SC-FDMA和下行为OFDMA
基于MATLAB 2022a的LTE通信链路SC-FDMA\/OFDMA仿真概览 在无线通信领域,LTE(Long-Term Evolution)采用创新的多址技术,上行为SC-FDMA(Single Carrier Frequency Division Multiple Access)和下行为OFDMA(Orthogonal Frequency Division Multiple Access),以实现高效频谱利用率和多用户并发通信。下面,我们将...
课程设计的题目:基于MATLAB的语音信号分析及滤波
这是我刚做的双线性变换法低通滤波器,运行是正确的!ly是语音信号的名字,别的自己改改就行!原语音信号程序 figure(1);[y,fs,nbits]=wavread ('ly');sound(y,fs,nbits); %回放语音信号 n = length (y) ; %求出语音信号的长度 Y=fft(y,n); %傅里叶变换 subplot(2,1,1);plo...
基于MATLAB的2FSK数字通信系统仿真
JIANGSUUNIVERSITY通信原理课程设计报告学院名称:专业班级:学生姓名:学生学号:基于MATLAB的2FSK数字通信系统仿真一、课程设计目的要求学生掌握2FSK的调制与解调的实现方法;遵循本系统的设计原则,理顺基带信号、传输频带及两个载频三者间相互间的关系;加深理解2FSK调制器与解调器的工作原理,学会对2FSK工作...
matlab在电气工程中的应用
请问你是想问“matlab在电气工程中的应用是什么”这个问题吗?以下是几个MATLAB在电气工程中的应用示例:1、控制系统设计与分析:MATLAB提供了丰富的控制工具箱,可以进行控制系统建模、分析和设计。2、电力电子系统建模与仿真:电力电子技术在电气工程中占据重要地位,包括电机控制、可再生能源转换等。3、...
基于MATLAB的数据采集系统的设计研究 开题报告怎么写?
的产品延伸了MATLAB的能力,包括数据采集,报告 生成,和依靠MATLAB语言编程产生独立C/C++代 码等等。正因为其强大的科学计算与可视化功能、简单易 用的开放式可扩展环境以及所拥有的各种面向不同领 域而扩展的工具箱(ToolBox)t11,使得MATLAB在许多 学科领域中成为计算机辅助设计与分析、算法研究和 应用...
基于MATLAB下的PID控制仿真
基于MATLAB下的PID控制仿真【摘要】自动化控制的参数的定值控制系统多采用P、I、D的组合控制。本文通过MATLAB软件用于直流伺服电机对单位阶跃信号输入的PID控制进行动态仿真,显示了不同作用组合和不同增益设置时的动态过程,为系统控制规律的选择和参数设定提供了依据。【关键词】自动化控制仿真直流伺服电机...
基于matlab的通信仿真系统设计
研究内容:运用MATLAB语言及SIMULINK仿真环境为工具,设计一种基于MATLAB的通信系统仿真平台GUI方案。开发出图形用户界面,设计一个通用的通信系统仿真平台。要求能够实现输入信号、信... 研究内容: 运用MATLAB语言及SIMULINK仿真环境为工具,设计一种基于MATLAB的通信系统仿真平台GUI方案。开发出图形用户界面,设计一个通用的通信...
matlab编程是什么语言?
matlab编程语言是:C++语言。Matlab是一个高级的矩阵\/阵列语言,它包含控制语句、函数、数据结构、输入和输出和面向对象编程特点。用户可以在命令窗口中将输入语句与执行命令同步,也可以先编写好一个较大的复杂的应用程序(M文件)后再一起运行。MATLAB语言是基于最为流行的C++语言基础上的,因此语法特征与...
文刷合心: function imf = emd(x,n);%%最好把函数名改为emd1之类的,以免和Grilling的emd冲突%%n为你想得到的IMF的个数 c = x('; % copy of the input signal (as a row vector) N = length(x);-% loop to decompose the input signal into n successive IMFs ...
安陆市18983173654: 谁可以给我一个emd分解的matlab程序.只需要emd分解的.谢谢了! - ?
文刷合心: %此版本为ALAN 版本的整合注释版 function imf = emd(x)% Empiricial Mode Decomposition (Hilbert-Huang Transform)% imf = emd(x)% Func : findpeaks x= transpose(x(:));%转置为行矩阵 imf = []; while ~ismonotonic(x) %当x不是单调函数,分...
安陆市18983173654: Matlab求瞬时频率(基于EMD)?
文刷合心: 你的EMD是% G. Rilling,的那个吗? len = size(imf,1); for k = 1:len len1 = length(imf(k,:)); b(k) = sum(imf(k,:).*imf(k,:))/len1;% 时域均方值,能量 amp(k,:) = abs(imf(k,:)); b(k) = sqrt(b(k)); th = angle(hilbert(imf(k,:)));%Hilbert变换的相位 d(k,:) = diff(th)/Ts/(2*pi);%求导,得到频率:f = (1/2*pi)*d(th)/dt end 你的频率公式用得有点问题,求出来不应是归一化频率
安陆市18983173654: 跪求一个emd去噪的程序matlab代码最好带点解释,方便理解,十分感谢,我真的不怎么懂这方面的! - ?
文刷合心: 你百度“EMD” 然后有个我爱春秋的博客 他的程序可以用 使用的时候 你需要把你的数据弄成横排的“123456” 竖排不行
安陆市18983173654: 用MATLAB实现EMD算法 - ?
文刷合心: ilovematlab论坛上可以免费下载,都可以运行
安陆市18983173654: 求非线性规划问题MATLAB程序代码,非常急 - ?
文刷合心: 首先建立目标函数myfun.m,然后保存 function f=myfun(x) f=x(1)+0.005*x(2)^2; 在命令行输入 x0=[0 0] A=[];b=[]; Aeq=[1 1];beq=135.25; [x,fval]=fmincon(@myfun,x0,[],[],Aeq,beq) x = 35.2496 100.0004 fval = 85.2500
安陆市18983173654: 急求EM算法的matlab实现代码 - ?
文刷合心: 1. EM算法程序:2. EM image segmentation:3. 贝叶斯图像分割程序:(Bayseian image segmentation) 没有找到合适的程序代码 :-(
安陆市18983173654: matlab emd工具箱使用 - ?
文刷合心: 其实用起来也很简单的,举个例子:clear all; 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); [m n]=size(imf); emd_visu(x,t,imf);
安陆市18983173654: MATLAB中的A=emd - visu(z,x,imf)是什么意思? - ?
文刷合心: A=调用函数emd_visu后的结果,其中z,x,imf都是函数里传递的参数,想知道这个函数是什么意思你得把这个函数的代码发上来
安陆市18983173654: 求用matlab求矩阵的伴随矩阵的秩的代码...急急急!!! - ?
文刷合心: 求伴随矩阵和矩阵的秩可以以下代码: A=magic(5);%矩阵A A=det(A)*inv(A);%求伴随矩阵 Az=rank(A);%求矩阵的秩用rank函数