THMMY's "Optimization Techniques" course assignments.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

20 line
513 B

  1. function [flag] = BelongsTo(x, SetLimmits)
  2. %Checks if the x vector belongs to Set
  3. %
  4. % x: A vector to project
  5. % SetLimmits: The set to project. Each line/dimension off the set has to contain the limits
  6. % of the set to that particular dimension
  7. % flag: True if belongs
  8. %
  9. flag = true; % Have faith
  10. for i = 1:size(SetLimmits, 2)
  11. if x(i) < SetLimmits(i,1)
  12. flag = false;
  13. elseif x(i) > SetLimmits(i,2)
  14. flag = false;
  15. end
  16. end
  17. end