This student's homework assignment is nothing useful. If anything, it teaches some poor programming practices. Jos makes some good points, and I agree with him on the rating. Part of me wanted to rate it even lower, but a 2 rating is a reasonable choice.
What do I like? This is a function, not a script, as many students seem to write. Because it is a function, it is much friendlier to the user than a script.
Other things I like are the fact that the author tried to provide help. Sadly, the author did it poorly. Also good is the preallocation of the returned variable.
What does the author need to do to improve this code? What don't I like here? Learn to write good help. Note that when you type "help fibonacci" on the command line, Matlab returns the entire initial block of comments, until it sees an empty line. In this code, the author put an empty line up front, so you only get ONE line - the information that this is for his "ECS 200 Project".
Next, learn to use the semicolon!!! Adding a ; after each line will prevent the unwanted display of every line as it is executed.
Add an H1 line. If the very first line of your help is a descriptive line that includes many useful keywords for your function, then lookfor will be able to find your function. Lookfor is a VERY useful utility. Learn to use it. Learn to enable it.
Finally, this is not very useful as a utility on the file exchange. Fibonacci numbers are not that useful to most people who will be on the FEX, except as a programming exercise for students. So even had the author repaired the above problems, I doubt that I'd have given this more than a 3 rating.
Had the author been creative here, providing several different options for generating Fibonacci numbers, I would have been more generous with my rating. There are at least two other schemes for generating Fibonacci numbers, one of which is quite pretty IMHO. Had the author provided reference links and code for each of these methods, perhaps described some variants, like Lucas numbers, etc., this would then have earned my appreciation.
This is the very simple, straighforward approach to compute Fibonnaci numbers, used in classroom assignments.
Imho, it's too simple to share here on the FEX. Using FILTER, e.g.,
filter(1,[1 -1 -1],[1 zeros(1,N-1)])
or matrix multiplication
f = [1 1 ; 1 0]^N ;
f = f(1,2)
is much more interesting.
I give this a 2-star rating because (1) the help is poorly formatted (typing "help fibonnaci" will only display the first, useless line), and (2) arguably the second fib. number is 1 and not 2.
I am happy to see that the author did use pre-allocation, but unfortunatyle he missed a semi-colon, so the function spits out values during execution ...