Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Index excedes matrix dimensions
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
soclydeza

Posts: 3
Registered: 12/6/12
Index excedes matrix dimensions
Posted: Dec 9, 2012 1:42 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Here is my code for a loop that generates the Fibonacci sequence for the input values.

******************************************
% Fibonacci
f(1) = input('Input first number in sequence ');
f(2) = input('Input second number in sequence ');
elem = input('Input number of elements ');
for j = 3:j
f(j) = f(j-1) + f(j-2);
end
disp(f(1:elem))
******************************************
Here's the thing, when I originally wrote this a few days ago it ran just fine for any input "elem" value up to 25. If I put in any number 25 or above, I got this message

Index exceeds matrix dimensions.

I opened it today, now it will only run for "elem" values 1 and 2, if I put 3 or above in I get the same thing,

Index exceeds matrix dimensions.

Error in Week10HW (line 35)
disp(f(1:elem))

I did not change any of the code. Can somebody help me out, I'm kind of lost as to what this is about. Thanks.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.