|
7-EMD端点效应优化(斜率匹配波形延拓法)(MATLAB视频)
百度网盘链接:https://pan.baidu.com/s/1eiMNqxuXBea7j6yw1-KZ4g
具体链接在halcom.cn论坛,联系人QQ:3283892722
该论坛是一个学习交流平台,我会逐一的和大家分享学习。
欢迎大家录制视频,你可在论坛进行打赏分享。
视频专用播放器:http://halcom.cn/forum.php?mod=viewthread&tid=258&extra=page%3D1\
主函数如下:- % 斜率匹配波形延拓法
- clc,clear,close all % 清理命令区、清理工作区、关闭显示图形
- warning off % 消除警告
- format short % 数据类型
- tic % 运算计时
- %% 初始化信号
- [t, signal] = gen_signal(5e3, 1e3);
- figure(1), plot(t,signal,'linewidth',1)
- xlabel('t'); ylabel('实际信号'); grid on;
- %% 斜率匹配波形延拓法
- %% 极值点和过零点位置提取
- [indmin, indmax, indzer] = extr(signal, t); % 极值点和过零点位置提取
- figure(2), plot(t,signal,'linewidth',1);
- hold on
- plot(t(indmin), signal(indmin), 'm.-')
- plot(t(indmax), signal(indmax), 'r.-')
- plot(t(indzer), signal(indzer), 'g.-')
- xlabel('t'); ylabel('实际信号'); grid on;
- legend('原始信号','极小值','极大值','过零点')
- axis tight;
- hold off;
- %% 斜率匹配波形延拓法
- if(indmax(1)<indmin(1))
- % 左端点沿拓
- index = find_first_indmin( indmax(1), indmin, 0 );
- index0 = find_first_indmin( indmax(1), indzer, 0 );
- A01 = (signal(indmax(1))-signal(indmin(index)))./( indmax(1)-indmin(index)+eps ); % M2-E0的斜率
- k=1;
- for i=2 : length(indmax)
- index = find_first_indmin( indmax(i), indmin, 0 );
- indexi = find_first_indmin( indmax(i), indzer, 0 );
- if(isempty(index))
- Scope(k,1)=inf;
- Amp(k,1) = inf;
- dt(k,1)=inf;
- else
- Scope(k,1)=(signal(indmax(i))-signal(indmin(index)))./( indmax(i)-indmin(index)+eps ); % M2-E0的斜率
- Amp(k,1) = abs( signal(indmax(1))-signal(indmax(i)) );
- dt(k,1) = abs( abs( indzer(index0)-indmax(1) ) - abs( indzer(indexi)-indmax(i) ) );
- end
- end
- k=k+1;
- [minV, index] = min(abs(Scope(:,1)-A01) + Amp + dt);
- newdata = signal( indmax(index) : indmax(index+1) );
- welddata_left = weld2( signal, newdata, indmax, 0 );
- % 右端点沿拓
- index = find_first_indmin( indmax(end), indmin, 1 );
- index0 = find_first_indmin( indmax(end), indzer, 1 );
- A01 = (signal(indmax(end))-signal(indmin(index)))./( indmax(end)-indmin(index)+eps ); % M2-E0的斜率
- k=1;
- for i=2 : length(indmax)
- index = find_first_indmin( indmax(i), indmin, 1 );
- indexi = find_first_indmin( indmax(i), indzer, 1 );
- if(isempty(index))
- Scope(k,1)=inf;
- Amp(k,1) = inf;
- dt(k,1)=inf;
- else
- Scope(k,1)=(signal(indmax(i))-signal(indmin(index)))./( indmax(i)-indmin(index)+eps ); % M2-E0的斜率
- Amp(k,1) = abs( signal(indmax(end))-signal(indmax(i)) );
- dt(k,1) = abs( abs( indzer(index0)-indmax(end) ) - abs( indzer(indexi)-indmax(i) ) );
- end
- end
- [minV, index] = min(abs(Scope(:,1)-A01)+Amp+dt);
- newdata = signal( indmax(index) : indmax(index+1) );
- welddata_right = weld2( signal, newdata, indmax, 1 );
- welddata = [welddata_left, signal(indmax(1):indmax(end)), welddata_right];
- figure(3),hold on
- plot(1:length(welddata_left), welddata_left,'r.-');
- plot(length(welddata_left)+1: length(welddata_left)+length(signal(indmax(1):indmax(end))),signal(indmax(1):indmax(end)),'b-');
- plot(length(welddata)-length(welddata_right)+1:length(welddata),welddata_right,'r.-');
- xlabel('t'); ylabel('实际信号'); grid on;
- axis tight;
- hold off;
-
- else
- signal = -1*signal;
- [indmin, indmax, indzer] = extr(signal, t); % 极值点和过零点位置提取
- % figure(22), plot(t,signal,'linewidth',1);
- % hold on
- % plot(t(indmin), signal(indmin), 'm.-')
- % plot(t(indmax), signal(indmax), 'r.-')
- % plot(t(indzer), signal(indzer), 'g.-')
- % xlabel('t'); ylabel('实际信号'); grid on;
- % legend('原始信号','极小值','极大值','过零点')
- % axis tight;
- % hold off;
-
- % 左端点沿拓
- index = find_first_indmin( indmax(1), indmin, 0 );
- index0 = find_first_indmin( indmax(1), indzer, 0 );
- A01 = (signal(indmax(1))-signal(indmin(index)))./( indmax(1)-indmin(index)+eps ); % M2-E0的斜率
- k=1;
- for i=2 : length(indmax)
- index = find_first_indmin( indmax(i), indmin, 0 );
- indexi = find_first_indmin( indmax(i), indzer, 0 );
- if(isempty(index))
- Scope(k,1)=inf;
- Amp(k,1) = inf;
- dt(k,1)=inf;
- else
- Scope(k,1)=(signal(indmax(i))-signal(indmin(index)))./( indmax(i)-indmin(index)+eps ); % M2-E0的斜率
- Amp(k,1) = abs( signal(indmax(1))-signal(indmax(i)) );
- dt(k,1) = abs( abs( indzer(index0)-indmax(1) ) - abs( indzer(indexi)-indmax(i) ) );
- end
- end
- k=k+1;
- [minV, index] = min(abs(Scope(:,1)-A01) + Amp + dt);
- newdata = signal( indmax(index) : indmax(index+1) );
- welddata_left = weld2( signal, newdata, indmax, 0 );
- % 右端点沿拓
- index = find_first_indmin( indmax(end), indmin, 1 );
- index0 = find_first_indmin( indmax(end), indzer, 1 );
- A01 = (signal(indmax(end))-signal(indmin(index)))./( indmax(end)-indmin(index)+eps ); % M2-E0的斜率
- k=1;
- for i=2 : length(indmax)
- index = find_first_indmin( indmax(i), indmin, 1 );
- indexi = find_first_indmin( indmax(i), indzer, 1 );
- if(isempty(index))
- Scope(k,1)=inf;
- Amp(k,1) = inf;
- dt(k,1)=inf;
- else
- Scope(k,1)=(signal(indmax(i))-signal(indmin(index)))./( indmax(i)-indmin(index)+eps ); % M2-E0的斜率
- Amp(k,1) = abs( signal(indmax(end))-signal(indmax(i)) );
- dt(k,1) = abs( abs( indzer(index0)-indmax(end) ) - abs( indzer(indexi)-indmax(i) ) );
- end
- end
- [minV, index] = min(abs(Scope(:,1)-A01)+Amp+dt);
- newdata = signal( indmax(index) : indmax(index+1) );
- welddata_right = weld2( signal, newdata, indmax, 1 );
- welddata = [welddata_left, signal(indmax(1):indmax(end)), welddata_right];
- % welddata = -1*welddata;
-
- figure(3),hold on
- plot(1:length(welddata_left), -welddata_left,'r.-');
- plot(length(welddata_left)+1: length(welddata_left)+length(signal(indmax(1):indmax(end))),-signal(indmax(1):indmax(end)),'b-');
- plot(length(welddata)-length(welddata_right)+1:length(welddata),-welddata_right,'r.-');
- xlabel('t'); ylabel('实际信号'); grid on;
- axis tight;
- hold off;
-
- end
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|