Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma rtGlobals=1        // Use modern global access method.
  2.  
  3. function kasia1(input)
  4. variable input // "input" will be the x values
  5. variable output=0 // output will be the y values
  6.  
  7.  
  8. variable slope1=0.4, slope2=-0.4, slope3=0, intercept1=0.5, intercept2=2.4, intercept3=0.5
  9. variable rangemax1=2.375, rangemax2=4.75-rangemax1, rangemax3=100-rangemax1-rangemax2, period=rangemax1+rangemax2+rangemax3
  10.  
  11. variable delta=0
  12. if(input<period)
  13.   delta=input
  14. else
  15.   delta=mod(input,period)
  16. endif
  17. //print delta, period, input
  18.  
  19. // zig-zag function
  20. if(delta<rangemax1)
  21.   output = slope1*delta + intercept1
  22. elseif(delta<rangemax2)
  23.   output = slope2*delta + intercept2
  24. else
  25.   output=slope3*delta+ intercept3
  26. endif
  27. return output
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement