Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- display("Hazi feladat")
- %{
- 1.
- %}
- function result = interval_add (v1, v2)
- if (isvector(v1) && length(v1) == 2 && isvector(v2) && length(v2) == 2)
- result = v1 + v2
- else
- error ("interval_add: expecting two vector with length of 2")
- endif
- endfunction
- function result = interval_sub (v1, v2)
- if (isvector(v1) && length(v1) == 2 && isvector(v2) && length(v2) == 2)
- result = [v1(1) - v2(2), v1(2) - v2(1)]
- else
- error ("interval_sub: expecting two vector with length of 2")
- endif
- endfunction
- function result = interval_mul (v1, v2)
- if (isvector(v1) && length(v1) == 2 && isvector(v2) && length(v2) == 2)
- a = v1(1)
- b = v1(2)
- c = v2(1)
- d = v2(2)
- result = [min([a*c,a*d,b*c,b*d]), max([a*c,a*d,b*c,b*d])]
- else
- error ("interval_mul: expecting two vector with length of 2")
- endif
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement