Advertisement
dhume878

FilterEMG

Aug 3rd, 2011
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.96 KB | None | 0 0
  1. close all; clear all; clc;
  2.  
  3. load EMGData.txt
  4. emg = EMGData(:,1);
  5.  
  6. [b,a]=butter(4,4/(960/2),'low');
  7.  
  8. n = length(a);
  9. z(n) = 0;
  10. Y = zeros(size(X));
  11. for m = 1:length(Y)
  12. %    disp(['b(0): ' num2str(b(1))]);
  13. %    disp(['X(m): ' num2str(X(m))]);
  14. %    disp(['z(0): ' num2str(z(1))]);
  15.    Y(m) = b(1) * X(m) + z(1);
  16. %    disp(['Y(m)=b(0)*X(m)+z(0) : ' num2str(Y(m))]);
  17.    for i = 2:n
  18. %       disp(['for i=' num2str(i-1)]);
  19. %       disp(['  b(' num2str(i-1) '):' num2str(b(i))]);
  20. %       disp(['  X(m):' num2str(X(m))]);
  21. %       disp(['  z(' num2str(i-1) '):' num2str(z(i))]);
  22. %       disp(['  a(' num2str(i-1) '):' num2str(a(i))]);
  23. %       disp(['  Y(m):' num2str(Y(m))]);
  24.       z(i - 1) = b(i) * X(m) + z(i) - a(i) * Y(m);
  25. %       disp(['Z(' num2str(i-2) ')=b(i)*X(m)+z(i)-a(i)*Y(m):' num2str(z(i-1))]);
  26.    end
  27. %   disp('--------------------------------------');
  28. end
  29. z = z(1:n - 1);
  30.  
  31. figure
  32. plot(X)
  33. hold on
  34. plot(Y,'LineWidth',3,'Color','black')
  35. axis tight
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement