Facebook
From Harmless Bat, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 64
  1. function [y,e] = sigmadelta(x)
  2.  
  3. N = length(x);
  4.  
  5. y = zeros(1,N);
  6. a = y;
  7. b = y;
  8. c = y;
  9. d = y;
  10. e = y;
  11.  
  12. for i = 1:1:N
  13. %for i = 2:1:N
  14.     iprev = max(1,i-1); % obchodzi iterowanie dla ujemnych 'i' dla poczatkowych indeksow
  15.    
  16.     d(i) = y(iprev);
  17.     %d(i) = y(i-1);
  18.     a(i) = x(i) - d(i);
  19.    
  20.     c(i) = b(iprev);
  21.     %c(i) = b(i-1);
  22.     b(i) = c(i) + a(i);
  23.    
  24.     if b(i)>0
  25.         y(i) = 1;
  26.     else
  27.         y(i) = -1;
  28.     end
  29.    
  30.     e(i) = y(i)-b(i);
  31. end
  32. end
  33.