This solution uses filter from the Signal Processing Toolbox.
Yes, it uses filter, but filter is indeed not a toolbox function, but a built-in function. You can fix the error by changing f=y(n-2) to f = y(n)
... and then change first input of filter to [1,-1] and remove +1 from the end of the line.
Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
%%
assert(isequal(fibonacci(1),1))
assert(isequal(fibonacci(2),1))
assert(isequal(fibonacci(5),5))
assert(isequal(fibonacci(7),13))
assert(isequal(fibonacci(13),233))
assert(isequal(fibonacci(15),610))
y =
2
|
54242 Solvers
The Hitchhiker's Guide to MATLAB
2874 Solvers
2334 Solvers
272 Solvers
Rounding off numbers to n decimals
1050 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!