Computer Science - MATLAB

posted by .

One interesting property of a Fibonacci sequence is that the ratio of the values of adjacent members of the sequence approach a number called “the golden ratio” or PHI. Create a program that accepts the first two numbers of a Fibonacci sequence as a user input and then calculates additional values in the sequence until the ratio of adjacent values converges to within 0.001. You can do this in a WHILE loop by comparing the ratio of element k to element k-1 and the ratio of element k-1 to element k-2. If you call your sequence x, then the code for the WHILE statement is

while abs(x(k)/x(k-1) – x(k-1)/x(k-2))>0.001

I think I'm doing something wrong... Here's my attempt at a solution

a=input('Please enter the first two numbers of the Fibonacci sequence in "[# #]" form. Do not enter [0 1] or [1 1]. Your free to enter anything else though.');
x=[a ones(1,100000)];
z=3;
while abs(x(z)/x(z-1)-x(z-1)/x(z-2))>0.001
x(z)=x(z-2)+x(z-1);
z=z+1;
end
g=x(find(x>1));

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. maths! please help me it is an emergency!!!!!!!!!!

    what is the fibonacci sequence and what is its relationship to the golden ratio?
  2. maths

    The common ratio r of a geometric sequence satisfies the quadratic equation 2r squared - 3r -2 = 0. If the sum to infinity of the same sequence is 6, explain why, in this case, r can only take on one value, and hence state the common …
  3. math

    The Fibonacci sequence of numbers begins 1,1,2,3,5,8,13,21,34,55,…and continues by the rule: every number is the sum of the two previous numbers. a. Determine the next five (eleventh through fifteenth) elements of this sequence. …
  4. Computer Science - MATLAB

    I guess it was skipped One interesting property of a Fibonacci sequence is that the ratio of the values of adjacent members of the sequence approach a number called “the golden ratio” or PHI. Create a program that accepts the first …
  5. Pre-Calc

    Find three examples of the Fibonacci sequence in nature. Write a paragraph for each example. For each example, address the following questions: How does the example relate to the Fibonacci sequence?
  6. Math (fibonacci

    A sequence of numbers is called a Fibonacci-type sequence if each number (after for the first two) is the sum of the two numbers which precede it. For example, 1, 1, 2, 3, 5, 8 ... is a Fibonacci- type sequence. If 1985, x, y, 200 …
  7. probability

    Problem 3: Checking the Markov property For each one of the following definitions of the state Xk at time k (for k=1,2,…), determine whether the Markov property is satisfied by the sequence X1,X2,…. A fair six-sided die (with sides …
  8. probability

    For each one of the following definitions of the state Xk at time k (for k=1,2,…), determine whether the Markov property is satisfied by the sequence X1,X2,…. A fair six-sided die (with sides labelled 1,2,…,6) is …
  9. Algebra

    I am so lost on these problems. Write a geometric sequence that starts with 3 and has a common ratio of 5. What is the 23rd term in the sequence. Write an arithmetic sequence that has a common difference of 4 and the eighth term is …
  10. Maths

    The Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, 21, ... starts with two 1s, and each term afterwards is the sum of its two predecessors. Which one of the ten digits is the last to appear in the units position of a number in the Fibonacci …

More Similar Questions