资源简介
Matlab实现的HHT中的波形匹配延拓
代码片段和文件信息
function [tmintmaxzminzmax] = boundary_matchwave(indminindmaxtx)
% 一种自适应波形匹配端点延拓法
% 输入参数说明: indmin 极小值地址序列
% indmax 极大值地址序列
% t 时间序列(时序)1:length(x)
% x 时间序列(值)
%
% 输出参数说明: tmin 极小值地址序列
% tmax 极大值地址序列
% zmin 极小值
% zmax 极大值
%
lx = length(x);
% 判断极值点个数
if (length(indmin) + length(indmax) < 3)
error(‘not enough extrema‘)
end
% 左端处理
leftmax = indmax(1);
leftmin = indmin(1);
if leftmin > leftmax
left = leftmin; % 左边处理长度
leftindex = indmin;
leftminind = indmax;
leftdisc = leftmax; % 末端长度
else
left = leftmax;
leftindex = indmax;
leftminind = indmin;
leftdisc = leftmin;
end;
leftvalue = x(1:left);
indexlen = length(leftindex);
mintol = 99999;
for i = 2:indexlen
len = leftindex(i);
leftvalue1 = x(len-left+1:len);
[tolerrextrx1] = SelfAdapMatchWave(leftvalueleftvalue1);
if tol < mintol
mintol = tol;
%avg=(sum(abs(extrx1))+sum(abs(rightvalue)))/(length(extrx1)*2-2);%有人说此处要改为leftvalue
avg=(sum(abs(extrx1))+sum(abs(leftvalue)))/(length(extrx1)*2-2);
erroo = leftvalue - extrx1;
avgerr=sum(abs(erroo))/(length(erroo)-1);
minextrx1 = extrx1;
newerr = err;
minindex = len;
indmini = i;
end
end;
%minextrx1
if (mintol < avg/(10*2) || mintol < avgerr*2) % 没有找到匹配子波左端处理取原始信号最左端的两个相邻极大值点的均值作为左端点的极大值,取信号最左端的两个相邻极小值点的均值作为左端点的极小值
lindmin = indmin(1)-indmin(2);
lvmin = (x(indmin(1))+x(indmin(2)))/2;
lindmax = indmax(1)-indmax(2);
lvmax = (x(indmax(1))+x(indmax(2)))/2;
else % 找到匹配子波左端处理
leftindex = leftminind(indmini);
leftx = x(leftindex-left-1:leftindex)+newerr;
leftx = [leftxx(1:2)];
[lhindminlhindmaxlhindzer] = extr(leftx);
lindmin = lhindmin(end)-(length(leftx)-2);
lindmax = lhindmax(end)-(length(leftx)-2);
lvmin = leftx(lhindmin(end));
lvmax = leftx(lhindmax(end));
end;
% 右端处理
rightmax = indmax(end);
rightmin = indmin(end);
if rightmin < rightmax
right = lx - rightmin; % 右边处理长度
rightindex = indmin;
rightmaxind = indmax;
rightdisc = lx - rightmax; % 末端长度
else
right = lx - rightmax;
rightindex = indmax;
rightmaxind = indmin;
rightdisc = lx - rightmin;
end;
righ
评论
共有 条评论