声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 3679|回复: 2

[经典算法] 请教大侠:有关五点二次平滑器消除趋势相的疑问

[复制链接]
发表于 2010-3-3 21:04 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
我用多项式拟合、五点二次平滑器和七点三次平滑器 对信号进行了趋势项的消除,请问结果为什么会有如此差别,请大侠指教,不甚感激。
代码如下:
  1. n=256;
  2. t = 0:0.001:0.255;
  3. y=(1.0e-005)*[-0.0682,0.0695,0.5921,0.8028,0.4183,-0.0552,0.0064,0.5177,0.7967,0.4697,-0.0335,-0.0493,0.4394,0.7807,0.5181,-0.0039,-0.0968,0.3588,0.7549,0.5624,0.0328,-0.1354,0.2772,0.7194,0.6011,0.0753,-0.1644,0.1960,0.6748,0.6332,0.1225,-0.1837,0.1168,0.6218,0.6577,0.1731,-0.1931,0.0410,0.5610,0.6736,0.2256,-0.1927,-0.0302,0.4936,0.6804,0.2786,-0.1828,-0.0955,0.4207,0.6776,0.3306,-0.1639,-0.1538,0.3436,0.6649,0.3801,-0.1368,-0.2042,0.2636,0.6423,0.4260,-0.1024,-0.2458,0.1821,0.6101,0.4667,-0.0617,-0.2781,0.1007,0.5685,0.5011,-0.0159,-0.3006,0.0207,0.5181,0.5282,0.0337,-0.3133,-0.0565,0.4598,0.5470,0.0857,-0.3161,-0.1293,0.3945,0.5569,0.1387,-0.3093,-0.1967,0.3233,0.5574,0.1912,-0.2934,-0.2575,0.2475,0.5480,0.2417,-0.2689,-0.3106,0.1683,0.5287,0.2889,-0.2369,-0.3552,0.0871,0.4996,0.3315,-0.1981,-0.3906,0.0055,0.4611,0.3681,-0.1539,-0.4164,-0.0751,0.4136,0.3978,-0.1054,-0.4324,-0.1534,0.3578,0.4195,-0.0540,-0.4385,-0.2278,0.2948,0.4324,-0.0012,-0.4349,-0.2972,0.2254,0.4361,0.0516,-0.4219,-0.3603,0.1510,0.4300,0.1029,-0.4002,-0.4160,0.0727,0.4140,0.1514,-0.3706,-0.4635,-0.0079,0.3882,0.1957,-0.3339,-0.5021,-0.0896,0.3527,0.2344,-0.2914,-0.5311,-0.1707,0.3081,0.2665,-0.2442,-0.5504,-0.2499,0.2550,0.2909,-0.1936,-0.5598,-0.3258,0.1943,0.3069,-0.1411,-0.5594,-0.3970,0.1269,0.3137,-0.0882,-0.5495,-0.4623,0.0540,0.3109,-0.0362,-0.5306,-0.5205,-0.0231,0.2982,0.0134,-0.5035,-0.5709,-0.1031,0.2756,0.0592,-0.4691,-0.6125,-0.1846,0.2433,0.0999,-0.4284,-0.6448,-0.2660,0.2017,0.1344,-0.3826,-0.6673,-0.3460,0.1514,0.1615,-0.3330,-0.6800,-0.4232,0.0931,0.1803,-0.2810,-0.6828,-0.4961,0.0278,0.1902,-0.2280,-0.6760,-0.5635,-0.0434,0.1906,-0.1755,-0.6601,-0.6242,-0.1193,0.1813,-0.1250,-0.6357,-0.6773,-0.1985,0.1620,-0.0778,-0.6036,-0.7219,-0.2796,0.1329,-0.0352,-0.5648,-0.7573,-0.3612,0.0944,0.0014,-0.5206,-0.7831,-0.4419,0.0469,0.0311,-0.4721,-0.7991,-0.5201,-0.0089,0.0528,-0.4207,-0.8052,-0.5946,-0.0719,0.1880,0.1880];
  4. figure(1);
  5. plot(t,y,'b');
  6. title('初始信号包含趋势项')
  7. axis([0,0.25,-0.000015,0.000015]);
  8. %采用二阶(m=2)多项式拟合去除趋势项
  9. m=2;
  10. ap=polyfit(t,y,m); %计算多项式待定系数向量a
  11. ap
  12. yd=y-polyval(ap,t); %用x减去多项式系数a生成的趋势项
  13. figure(2)
  14. plot(t,yd);
  15. title('采用多项式拟合去除趋势项后的位移信号')
  16. axis([0,0.25,-0.000015,0.000015]);


  17. h=[-3,12,17,12,-3]';
  18. y1(1)=y(1)-(1/70)*(69*y(1)+4*(y(2)+y(4))-6*y(3)-y(5));
  19. y1(2)=y(2)-(1/35)*(2*(y(1)+y(5))+27*y(2)+12*y(3)-8*y(4));
  20. for i=3:(n-2)
  21. yDTemp=[y(i-2),y(i-1),y(i),y(i+1),y(i+2)];
  22. trendTemp=(yDTemp*h)/35;
  23. y1(i)=y(i)-trendTemp;
  24. end;
  25. y1(n-1)=y(n-1)-(1/35)*(2*(y(n-4)+y(n))-8*y(n-3)+12*y(n-2)+27*y(n-1));
  26. y1(n)=y(n)-(1/70)*(-y(n-4)+4*(y(n-3)+y(n-1))-6*y(n-2)+69*y(n));
  27. figure(3)
  28. plot(t,y1);
  29. grid;
  30. title('采用savitzky-golay五点二次平滑器去除趋势项后的位移信号')
  31. axis([0,0.25,-0.000015,0.000015]);

  32. h2=[-2,3,6,7,6,3,-2]';
  33. %这里如何修改?
  34. y2(1)=y(1);
  35. y2(2)=y(2);
  36. y2(3)=y(3);

  37. for i=4:(n-3)
  38. yDTemp=[y(i-3),y(i-2),y(i-1),y(i),y(i+1),y(i+2),y(i+3)];
  39. trendTemp=(yDTemp*h2)/21;
  40. y2(i)=y(i)-trendTemp;
  41. end;
  42. %这里如何修改?
  43. y2(n-2)=y(n-2)-trendTemp;
  44. y2(n-1)=y(n-1)-trendTemp;
  45. y2(n)=y(n)-trendTemp;
  46. figure(4)
  47. plot(t,y2);
  48. grid;
  49. title('采用savitzky-golay七点三次平滑器去除趋势项后的位移信号')
  50. axis([0,0.25,-0.000015,0.000015]);
复制代码

运行结果:
file:///C:/Documents%20and%20Settings/Administrator/桌面/g4.jpg

file:///C:/Documents%20and%20Settings/Administrator/桌面/g3.jpg

file:///C:/Documents%20and%20Settings/Administrator/桌面/g2.jpg

file:///C:/Documents%20and%20Settings/Administrator/桌面/g1.jpg
主要的差别在于信号幅度,请问是什么原因?各种算法该做什么样的改进呢?

[ 本帖最后由 李元 于 2010-3-3 21:16 编辑 ]
回复
分享到:

使用道具 举报

 楼主| 发表于 2010-3-17 17:29 | 显示全部楼层

回复 楼主 李元 的帖子

经过学习,觉得原因是:采用多项式拟合的方法是一种理论上的方法,得出的信号大体与理论信号一致;然而叉点叉次平滑器的理论基础是多项式拟合,当点数和次数选取合适的时候,效果可以接近多项式拟合的方法。在这里,选取的次数和点数增加的时候,信号的能量损失变小,波形接近多项式拟合的效果。
但是出现了新问题,请路过的大侠给予提示——在使用平滑器或者多项式拟合对信号趋势项去除的时候会导致信号能量损失,请问如何补偿这个损失?
谢谢,等待…
发表于 2010-8-9 13:00 | 显示全部楼层

回复 楼主 李元 的帖子

楼主的五点二次平滑器和七点三次平滑器的系数是如何确定的?有没有理论根据?还是仅仅凭借的是经验值?
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-12-23 14:38 , Processed in 0.061295 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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