Advertisement
Guest User

Pidgonacci

a guest
Jun 9th, 2012
1,535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.45 KB | None | 0 0
  1. clear all;
  2.  
  3. % Pidgeon locations in pixels
  4. x = [39, 48, 60, 77, 93, 116, 140, 172, 209, 256, 312, 418, 629].'
  5. n = size(x)
  6.  
  7. % Fibonacci, variable a is for shifting all the locations
  8. cvx_begin
  9.     variables x_fib(n) a
  10.     minimize norm(x_fib - (x - a))
  11.     subject to
  12.         x_fib(1:n-2) + x_fib(2:n-1) == x_fib(3:n)
  13.         2 * x_fib(1) == x_fib(2)
  14. cvx_end
  15.  
  16. % Quadratic
  17. p = polyfit([1:n].', x, 2)
  18. p_objective = norm(polyval(p, [1:n].') - x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement