Rich (BB code):
clear
n = 10;
F = Fib(n);
% Create, Fn a (10x2) array
Fn = [(1:n)' F];
% Print Fn to command window
fprintf('\n Fib number F_%g = %g \n',Fn')
%Part C
F_ratio = F(2:n)./F(1:n-1);
F_r = [(1:n-1)' F_ratio];
%Part D
phi = (1+(sqrt(5)))/2;
fprintf('\n Fib number F_ratio_%g = %g \n',F_r')
abs_diff = abs(phi - F_r);
fprintf('\n Absolute difference between F_ratio_%g and golden mean = %g \n', abs_diff')
" Fib number F_ratio 1 = its ratio"
" Absolute difference between F_ratio and Golden mean = its difference"
And it should repeat for the remaining 8 times.
However I'm getting the following displayed:
" Fib number F_ratio 1 = its ratio"
upto
" Fib number F_ratio 9 = its ratio"
Then
" Absolute difference between F_ratio (its difference) and Golden mean = its difference here too"
I'm not quite sure as where too I'm going wrong..
Any help much appreciated
Many thanks
Matt
Last edited: