Fibonacci numbers in MATLAB

Example for versions GNU Octave 3.2.3

This example uses recursive definition of Fibonacci numbers.

function f = fib(n)
  if (n <= 1)
    f = n;
  else
    f = fib(n - 1) + fib(n - 2);
  endif
endfunction

for i = 1 : 16
  printf("%d, ", fib(i));
endfor
disp("...");