Problem with Fibonacci For loop

조회 수: 2 (최근 30일)
Mary Jeppson
Mary Jeppson 2016년 5월 12일
댓글: Mary Jeppson 2016년 5월 13일
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에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by