Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Pidgonacci

By: a guest on Jun 9th, 2012  |  syntax: MatLab  |  size: 0.45 KB  |  hits: 1,433  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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)