Question: A function is said to be recursive if the function calls itself. MATLAB functions are designed to allow recursive operation. To test this fea-
A function is said to be recursive if the function calls itself. MATLAB functions are designed to allow recursive operation. To test this fea- ture, write a MATLAB function that derives the Fibonacci numbers. The nth Fibonacci number is defined by the equation: F A F 1 n-1 + F n-2 n> 1 n = 1 n=0 (7.10) where n is a non-negative integer. The function should check to make sure that there is a single argument n, and that n is a non-negative integer. If it is not, generate an error using the error function. If the input argument is a non- negative integer, the function should evaluate F using Equation (7.10). Test your function by calculating the Fibonacci numbers for n = 1, n = 5, and n = 10.
Step by Step Solution
3.32 Rating (158 Votes )
There are 3 Steps involved in it
Sure Heres an example MATLAB function that implements the Fibonacci sequence recursively matlab func... View full answer
Get step-by-step solutions from verified subject matter experts
