Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. X/25, 0 <= x <= 5
  2.  
  3. 2/5-x/25, 5 <= x <= 10
  4.  
  5. 0, otherwise
  6.  
  7. function [y] = f( x )
  8.  
  9. if (x>=0 && x<=5)
  10. y = x/25;
  11. elseif (x>=5 && x<=10)
  12. y =2/5-x/25;
  13. else
  14. y=0;
  15. end
  16.  
  17. end
  18.  
  19. function [y] = f( x )
  20.  
  21. n = numel(x);
  22. y = zeros(1,n);
  23.  
  24. for k = 1:n
  25. if (x(k)>=0 && x(k)<=5)
  26. y(k) = x(k)/25;
  27. elseif (x(k)>=5 && x(k)<=10)
  28. y(k) =2/5-x(k)/25;
  29. else
  30. y(k)=0;
  31. end
  32.  
  33. end
  34.  
  35. x = 0:0.1:15;
  36. y = f(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement