SHARE
TWEET

Pidgonacci

a guest Jun 9th, 2012 1,464 Never
  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)
RAW Paste Data
Top