Problem with Fibonacci For loop

3 次查看(过去 30 天)
Mary Jeppson
Mary Jeppson 2016-5-12
Here is my code:
f(1) = input('What is the first number of the sequence?')
f(2) = input('What is the second number?')
n = input('How many elements would you like to calculate?')
for k = 3:n
f(k) = f(k-2)+f(k-1)
end
Why am I exceeding matrix dimensions? Thanks for your help.
  2 个评论
Jos (10584)
Jos (10584) 2016-5-12
It runs fine with me. When and where does the error occur?
Mary Jeppson
Mary Jeppson 2016-5-13
Thanks Jos,the program stopped reporting the error. Thank you for your reply.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by