Fibonacci in Matlab

Published on 24 October 2019 (Updated: 05 November 2019)

Welcome to the Fibonacci in Matlab page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

function f = fibonacci(n)

if ischar(n)
	error('Usage: please input the count of fibonacci numbers to output')
end

if n < 0
	error('Usage: please input a non-negative integer')
end

if not(n==round(n))
	error('Usage: please input an integer, not a floating point')
end


a(1) = 1;
a(2) = 1;


for i=1:n
  a(i+2)=a(i+1)+a(i);
end

f = mat2str(a);

end

Fibonacci in Matlab was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.