fibonacci series in matlab

5 visualizaciones (últimos 30 días)
Wale Omole
Wale Omole el 22 de Nov. de 2015
Editada: the cyclist el 23 de Nov. de 2015
function f = fibnum(n)
% fibnum Fibonacci number
% fibnum(n) generates the nth Fibonacci number
if n <= 1 f = 1;
else f = fibnum(n-1) + fibnum(n-2);
end
Geting error when I type in command window
>> fibnum(12)
Undefined function or variable 'fibnum'.

Respuestas (1)

the cyclist
the cyclist el 23 de Nov. de 2015
Editada: the cyclist el 23 de Nov. de 2015
I'm guessing that the function is not on the search path (where MATLAB will look for functions to execute).
What is the result of
which fibnum
?
You can use the addpath command to add the directory where that function is to your path.

Categorías

Más información sobre Search Path en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by