I am new to matlab and am trying to write a function which produces the Fibonacci sequence of input n. I am required to write it in a way so that the program returns all Fibonacci numbers which are less than 3000, including the index of the highest term below 3000. However, I kept getting the error ( Index exceeds matrix dimensions ) at where the if loops is located. May i know how I can change it to make it work?
y(i) = y(i-1)+y(i-2);
if y(i) > 3000