No problem. I changed it to run 1:9 times which means it will run the loop for nine times right?

The problem was it just repeated the whole issue 9 times, where as if I left it at 1 it just ran once with the issues ive been having.

Many thanks
MAtt

Click to expand...

I see, I see.

Alright, this is what I think needs to be done: F_ratio and F_r or whatever second variable you use, are matrices right, containing the different 9 instances you want to show?

For example, F_ratio(1) is the first one, F_ratio(2) is the second, etc.?

So instead of

Code ( (Unknown Language)):

for j=1:9,

fprintf('\n Fib number F_ratio_%g = %g \n',F_r')

fprintf('\n Absoulute difference %g = %g \n',abs_diff')

end

Your code could do something like:

Code ( (Unknown Language)):

for j=1:9,

fprintf('\n Fib number F_ratio_%g = %g \n',F_r(j)')

fprintf('\n Absoulute difference %g = %g \n',abs_diff(j)')

end

That should fix the problem. Good luck,
-blazed

Edit: Remember, you know what your code is better than I, so you should adjust this for your specific case. For example, a quick look at your code indicates F_r is a 9x2 matrix, so instead of F_r(j) you need to do F_r(j,1)...

Great. Mostly your task is complete. Now your problem is simply debugging your code. I would do it for you, but it's a simple skill that if you ever program is something useful to be able to do.

You know you have an error with a certain variable (in this case F_r), so start by tracking that variable every step of the way. In your cause, you only really assign it a value once, when you create it, but sometimes that's not always the case.

In your case, just display it after you made it, either by removing the semicolon or typing disp(F_r). That should show you all the values stored in the matrix. If you see nothing, then something is wrong with your assignment of the variable. Try doing the same thing in a different way or just looking to see if there's something wrong. May I ask why you have an apostrophe after the parenthesis?