|
8-EMD端点效应优化(最大相关波形延拓法)(MATLAB视频)
百度网盘链接:https://pan.baidu.com/s/1bYIuE0r10SEVqMSWDSTZhg
具体链接在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;
- %% 最大相关波形延拓法
- flag=0; % =0就是左端点沿拓;=1就是右端点沿拓
- signal_corr = maxCorr_find_Si(signal, t, 0);
- newdata = signal_corr;
- welddata_left = weld( signal, newdata, indmax, 0 );
- flag=1; % =0就是左端点沿拓;=1就是右端点沿拓
- signal_corr = maxCorr_find_Si(signal, t, 1);
- newdata = signal_corr(end:-1:1);
- welddata_right = weld( 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;
复制代码 关键性函数如下:- function signal_corr = maxCorr_find_Si(signal, t, flag)
- % 最大相关波形延拓法
- if(flag==0)
- k=1;
- [indmin, indmax, indzer] = extr(signal, t); % 极值点和过零点位置提取
- for j=1:length(indmax)
- if(indmax(j)>indzer(1))
- break;
- end
- end
- w0 = signal( indzer(1):indmax(j+1) );
- h0 = signal(indmax(j)) - signal(1);
- for i=2:length(indmax)
- signal = signal + h0-signal(indmax(i));
- [indmini, indmaxi, indzeri] = extr(signal, t); % 极值点和过零点位置提取
- if(isempty(indzeri))
- break;
- else
- for j=1:length(indmaxi)
- if(indmaxi(j)>indzeri(1))
- break;
- end
- end
- w = signal( indzeri(1):indmaxi(j+1) );
- w = imresize(w, size(w0));
- xx = corrcoef( w0, w );
- Corr1(k,1) = xx(1,2);
- w1 = signal( indmaxi(i-1):indmaxi(i) );
- w1 = imresize(w1, size(w0));
- Corr2(k,:) = w1;
- k=k+1;
- end
- end
- [maxP, index] = max(Corr1);
- signal_corr = Corr2(index,:);
- elseif(flag==1)
- k=1;
- signal = signal(end:-1:1);
- [indmin, indmax, indzer] = extr(signal, t); % 极值点和过零点位置提取
- for j=1:length(indmax)
- if(indmax(j)>indzer(1))
- break;
- end
- end
- w0 = signal( indzer(1):indmax(j+1) );
- h0 = signal(indmax(j)) - signal(1);
- for i=2:length(indmax)
- signal = signal + h0-signal(indmax(i));
- [indmini, indmaxi, indzeri] = extr(signal, t); % 极值点和过零点位置提取
- if(isempty(indzeri))
- break;
- else
- for j=1:length(indmaxi)
- if(indmaxi(j)>indzeri(1))
- break;
- end
- end
- w = signal( indzeri(1):indmaxi(j+1) );
- w = imresize(w, size(w0));
- xx = corrcoef( w0, w );
- Corr1(k,1) = xx(1,2);
- w1 = signal( indmaxi(i-1):indmaxi(i) );
- w1 = imresize(w1, size(w0));
- Corr2(k,:) = w1;
- k=k+1;
- end
- end
- [maxP, index] = max(Corr1);
- signal_corr = Corr2(index,:);
- end
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|