How to create a vector of the ratio of two successive Fibonacci numbers

n=input('Your Fibonacci sequence number that you want to find between 20 and 40 is ')
f=zeros(n,1);
f(1)=1;
f(2)=1;
for x=3:n;
f(x)=f(x-1)+f(x-2);
end
sprintf('Your fibo sequence is')
f
This part of the code was to create a vector of a fibonacci series to a user inputted number n, but what I can't figure out is the title. Creating and plotting a vector length (n-1) that will plot the ratio of two successive fibonacci numbers. i.e. plotting the Golden Ratio

回答 (1 件)

Orion
Orion 2014 年 10 月 15 日
Hi,
try this
figure;
plot(f(2:end)./f(1:end-1))

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

質問済み:

2014 年 10 月 15 日

回答済み:

2014 年 10 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by