Code covered by the BSD License  

Highlights from
mlunit_2008a

image thumbnail
from mlunit_2008a by Christopher
A MATLAB unit test framework supporting new classdef files (r2008a)

fib(x)
function y = fib(x)
% Simple queue implementation of Fibonacci function..

if x < 0 || (int64(x) ~= x)
    error('invalid input: please input only non-negative integers.');
end

if x < 2, y = x; return; end
q = [0 1];

for k = 2:x
    q = [q sum(q)];
    q(1) = [];
end

y = q(2);

Contact us at files@mathworks.com