MATLAB Answers

mary freiling

can someone write this out in matlab format so i can check that my homework answer was correct? Write a MATLAB program in a script file that determines and displays the first 20 Fibonacci numbers.

Asked by mary freiling
on 18 Nov 2013
Latest activity Commented on by Yash
on 21 Nov 2013
Write a MATLAB program in a script file that determines and displays the first 20 Fibonacci numbers.

  1 Comment

Yash
on 21 Nov 2013

f = zeros(n,1);

f(1) = 1;
f(2) = 2;
for k = 3:n
f(k) = f(k-1) + f(k-2);
end

Tags

Products

No products are associated with this question.

1 Answer

Answer by Image Analyst
on 18 Nov 2013

You can look up the first 20 Fibonacci numbers anywhere to check your answer. If your code produces them, it works. Why do you need us for that?

  0 Comments


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today