Hello Mat

 找回密码
 立即注册
查看: 6972|回复: 0

7-EMD端点效应优化(斜率匹配波形延拓法)(MATLAB视频)

[复制链接]

1323

主题

1551

帖子

0

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22647
发表于 2018-9-1 22:20:16 | 显示全部楼层 |阅读模式
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\

主函数如下:
  1. % 斜率匹配波形延拓法
  2. clc,clear,close all % 清理命令区、清理工作区、关闭显示图形
  3. warning off         % 消除警告
  4. format short        % 数据类型
  5. tic                 % 运算计时
  6. %% 初始化信号
  7. [t, signal] = gen_signal(5e3, 1e3);
  8. figure(1), plot(t,signal,'linewidth',1)
  9. xlabel('t');  ylabel('实际信号');  grid on;
  10. %% 斜率匹配波形延拓法
  11. %% 极值点和过零点位置提取
  12. [indmin, indmax, indzer] = extr(signal, t); % 极值点和过零点位置提取
  13. figure(2), plot(t,signal,'linewidth',1);
  14. hold on
  15. plot(t(indmin), signal(indmin), 'm.-')
  16. plot(t(indmax), signal(indmax), 'r.-')
  17. plot(t(indzer), signal(indzer), 'g.-')
  18. xlabel('t');  ylabel('实际信号');  grid on;
  19. legend('原始信号','极小值','极大值','过零点')
  20. axis tight;
  21. hold off;
  22. %% 斜率匹配波形延拓法
  23. if(indmax(1)<indmin(1))
  24.     % 左端点沿拓
  25.     index = find_first_indmin( indmax(1), indmin, 0 );
  26.     index0 = find_first_indmin( indmax(1), indzer, 0 );
  27.     A01 = (signal(indmax(1))-signal(indmin(index)))./( indmax(1)-indmin(index)+eps ); % M2-E0的斜率
  28.     k=1;
  29.     for i=2 : length(indmax)
  30.         index = find_first_indmin( indmax(i), indmin, 0 );
  31.         indexi = find_first_indmin( indmax(i), indzer, 0 );
  32.         if(isempty(index))
  33.             Scope(k,1)=inf;
  34.             Amp(k,1) = inf;
  35.             dt(k,1)=inf;
  36.         else
  37.             Scope(k,1)=(signal(indmax(i))-signal(indmin(index)))./( indmax(i)-indmin(index)+eps ); % M2-E0的斜率
  38.             Amp(k,1) = abs( signal(indmax(1))-signal(indmax(i)) );
  39.             dt(k,1) = abs( abs( indzer(index0)-indmax(1) ) - abs( indzer(indexi)-indmax(i) ) );
  40.         end
  41.     end
  42.     k=k+1;
  43.     [minV, index] = min(abs(Scope(:,1)-A01) + Amp + dt);
  44.     newdata = signal( indmax(index) : indmax(index+1) );
  45.     welddata_left = weld2( signal, newdata, indmax, 0 );
  46.     % 右端点沿拓
  47.     index = find_first_indmin( indmax(end), indmin, 1 );
  48.     index0 = find_first_indmin( indmax(end), indzer, 1 );
  49.     A01 = (signal(indmax(end))-signal(indmin(index)))./( indmax(end)-indmin(index)+eps ); % M2-E0的斜率
  50.     k=1;
  51.     for i=2 : length(indmax)
  52.         index = find_first_indmin( indmax(i), indmin, 1 );
  53.         indexi = find_first_indmin( indmax(i), indzer, 1 );
  54.         if(isempty(index))
  55.             Scope(k,1)=inf;
  56.             Amp(k,1) = inf;
  57.             dt(k,1)=inf;
  58.         else
  59.             Scope(k,1)=(signal(indmax(i))-signal(indmin(index)))./( indmax(i)-indmin(index)+eps ); % M2-E0的斜率
  60.             Amp(k,1) = abs( signal(indmax(end))-signal(indmax(i)) );
  61.             dt(k,1) = abs( abs( indzer(index0)-indmax(end) ) - abs( indzer(indexi)-indmax(i) ) );
  62.         end
  63.     end
  64.     [minV, index] = min(abs(Scope(:,1)-A01)+Amp+dt);
  65.     newdata = signal( indmax(index) : indmax(index+1) );
  66.     welddata_right = weld2( signal, newdata, indmax, 1 );

  67.     welddata = [welddata_left, signal(indmax(1):indmax(end)), welddata_right];

  68.     figure(3),hold on
  69.     plot(1:length(welddata_left), welddata_left,'r.-');
  70.     plot(length(welddata_left)+1: length(welddata_left)+length(signal(indmax(1):indmax(end))),signal(indmax(1):indmax(end)),'b-');
  71.     plot(length(welddata)-length(welddata_right)+1:length(welddata),welddata_right,'r.-');
  72.     xlabel('t');  ylabel('实际信号');  grid on;
  73.     axis tight;
  74.     hold off;
  75.    
  76. else
  77.     signal = -1*signal;
  78.     [indmin, indmax, indzer] = extr(signal, t); % 极值点和过零点位置提取
  79. %     figure(22), plot(t,signal,'linewidth',1);
  80. %     hold on
  81. %     plot(t(indmin), signal(indmin), 'm.-')
  82. %     plot(t(indmax), signal(indmax), 'r.-')
  83. %     plot(t(indzer), signal(indzer), 'g.-')
  84. %     xlabel('t');  ylabel('实际信号');  grid on;
  85. %     legend('原始信号','极小值','极大值','过零点')
  86. %     axis tight;
  87. %     hold off;
  88.    
  89.     % 左端点沿拓
  90.     index = find_first_indmin( indmax(1), indmin, 0 );
  91.     index0 = find_first_indmin( indmax(1), indzer, 0 );
  92.     A01 = (signal(indmax(1))-signal(indmin(index)))./( indmax(1)-indmin(index)+eps ); % M2-E0的斜率
  93.     k=1;
  94.     for i=2 : length(indmax)
  95.         index = find_first_indmin( indmax(i), indmin, 0 );
  96.         indexi = find_first_indmin( indmax(i), indzer, 0 );
  97.         if(isempty(index))
  98.             Scope(k,1)=inf;
  99.             Amp(k,1) = inf;
  100.             dt(k,1)=inf;
  101.         else
  102.             Scope(k,1)=(signal(indmax(i))-signal(indmin(index)))./( indmax(i)-indmin(index)+eps ); % M2-E0的斜率
  103.             Amp(k,1) = abs( signal(indmax(1))-signal(indmax(i)) );
  104.             dt(k,1) = abs( abs( indzer(index0)-indmax(1) ) - abs( indzer(indexi)-indmax(i) ) );
  105.         end
  106.     end
  107.     k=k+1;
  108.     [minV, index] = min(abs(Scope(:,1)-A01) + Amp + dt);
  109.     newdata = signal( indmax(index) : indmax(index+1) );
  110.     welddata_left = weld2( signal, newdata, indmax, 0 );
  111.     % 右端点沿拓
  112.     index = find_first_indmin( indmax(end), indmin, 1 );
  113.     index0 = find_first_indmin( indmax(end), indzer, 1 );
  114.     A01 = (signal(indmax(end))-signal(indmin(index)))./( indmax(end)-indmin(index)+eps ); % M2-E0的斜率
  115.     k=1;
  116.     for i=2 : length(indmax)
  117.         index = find_first_indmin( indmax(i), indmin, 1 );
  118.         indexi = find_first_indmin( indmax(i), indzer, 1 );
  119.         if(isempty(index))
  120.             Scope(k,1)=inf;
  121.             Amp(k,1) = inf;
  122.             dt(k,1)=inf;
  123.         else
  124.             Scope(k,1)=(signal(indmax(i))-signal(indmin(index)))./( indmax(i)-indmin(index)+eps ); % M2-E0的斜率
  125.             Amp(k,1) = abs( signal(indmax(end))-signal(indmax(i)) );
  126.             dt(k,1) = abs( abs( indzer(index0)-indmax(end) ) - abs( indzer(indexi)-indmax(i) ) );
  127.         end
  128.     end
  129.     [minV, index] = min(abs(Scope(:,1)-A01)+Amp+dt);
  130.     newdata = signal( indmax(index) : indmax(index+1) );
  131.     welddata_right = weld2( signal, newdata, indmax, 1 );

  132.     welddata = [welddata_left, signal(indmax(1):indmax(end)), welddata_right];

  133. %     welddata = -1*welddata;
  134.    
  135.     figure(3),hold on
  136.     plot(1:length(welddata_left), -welddata_left,'r.-');
  137.     plot(length(welddata_left)+1: length(welddata_left)+length(signal(indmax(1):indmax(end))),-signal(indmax(1):indmax(end)),'b-');
  138.     plot(length(welddata)-length(welddata_right)+1:length(welddata),-welddata_right,'r.-');
  139.     xlabel('t');  ylabel('实际信号');  grid on;
  140.     axis tight;
  141.     hold off;
  142.    
  143. end
复制代码



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-11-22 16:11 , Processed in 0.220593 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表