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.

19 lines
554 B

  1. function [x_p] = ProjectionPoint(x, SetLimmits)
  2. %Project the x vector to Set, returns a point of Set close(st) to x
  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. %x_p: The projected point
  8. %
  9. x_p = x;
  10. for i = 1:size(SetLimmits, 2)
  11. if x(i) < SetLimmits(i,1)
  12. x_p(i) = SetLimmits(i,1);
  13. elseif x(i) > SetLimmits(i,2)
  14. x_p(i) = SetLimmits(i,2);
  15. end
  16. end
  17. end