Rank: 5079 based on 2 downloads (last 30 days) and 1 file submitted
photo

Jesse

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by Jesse
Updated   File Tags Downloads
(last 30 days)
Comments Rating
03 Dec 2007 Fibonacci Number Generator This is a program that generates any desired amount of fibonacci numbers. Author: Jesse fibonacci, numbers, sequence, n, mathematics 2 4
  • 2.0
2.0 | 2 ratings
Comments and Ratings on Jesse's Files View all
Updated File Comment by Comments Rating
06 Dec 2007 Fibonacci Number Generator This is a program that generates any desired amount of fibonacci numbers. Author: Jesse D'Errico, John

My personal favorite is this:

for n = 1:10
  det(spdiags(ones(n,3)*diag([-i 1 -i]),[-1 0 1],n,n))
end

ans =
     1
ans =
     2
ans =
     3
ans =
     5
ans =
     8
ans =
    13
ans =
    21
ans =
    34
ans =
    55
ans =
    89

The reason for why this works is fairly easy to uncover. But dig just a bit deeper, and it will lead to some pretty mathematics.

05 Dec 2007 Fibonacci Number Generator This is a program that generates any desired amount of fibonacci numbers. Author: Jesse B., Olivier

I give 5 stars for filter(1,[1 -1 -1],[1 zeros(1,N-1)]) !

04 Dec 2007 Fibonacci Number Generator This is a program that generates any desired amount of fibonacci numbers. Author: Jesse D'Errico, John

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.

04 Dec 2007 Fibonacci Number Generator This is a program that generates any desired amount of fibonacci numbers. Author: Jesse x@y.z, Jos

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 ...

Top Tags Applied by Jesse
fibonacci, mathematics, n, numbers, sequence
Files Tagged by Jesse
Updated   File Tags Downloads
(last 30 days)
Comments Rating
03 Dec 2007 Fibonacci Number Generator This is a program that generates any desired amount of fibonacci numbers. Author: Jesse fibonacci, numbers, sequence, n, mathematics 2 4
  • 2.0
2.0 | 2 ratings

Contact us at files@mathworks.com