Advertisement
Guest User

Untitled

a guest
Sep 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.86 KB | None | 0 0
  1. display("Hazi feladat")
  2.  
  3. %{
  4. 1.
  5. %}
  6.  
  7. function result = interval_add (v1, v2)
  8.   if (isvector(v1) && length(v1) == 2 && isvector(v2) && length(v2) == 2)
  9.     result = v1 + v2
  10.   else  
  11.     error ("interval_add: expecting two vector with length of 2")
  12.   endif
  13. endfunction  
  14.  
  15. function result = interval_sub (v1, v2)
  16.   if (isvector(v1) && length(v1) == 2 && isvector(v2) && length(v2) == 2)
  17.     result = [v1(1) - v2(2), v1(2) - v2(1)]
  18.   else  
  19.     error ("interval_sub: expecting two vector with length of 2")
  20.   endif
  21. endfunction  
  22.  
  23. function result = interval_mul (v1, v2)
  24.   if (isvector(v1) && length(v1) == 2 && isvector(v2) && length(v2) == 2)
  25.     a = v1(1)
  26.     b = v1(2)
  27.     c = v2(1)
  28.     d = v2(2)
  29.     result = [min([a*c,a*d,b*c,b*d]), max([a*c,a*d,b*c,b*d])]
  30.   else  
  31.     error ("interval_mul: expecting two vector with length of 2")
  32.   endif
  33. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement