fibonacci series in matlab

5 次查看(过去 30 天)
Wale Omole
Wale Omole 2015-11-22
编辑: the cyclist 2015-11-23
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'.

回答(1 个)

the cyclist
the cyclist 2015-11-23
编辑:the cyclist 2015-11-23
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.

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by