0, 1, 1, 2, 3, 5, 8, 13, , a Fibonacci sequence can be created with any two starting numbers (a, b). Write an m-file that calculates the Fibonacci sequence (10 terms long) as a vector using and b = 8. Use fprintf() to output the sequence. You may want to use num2str() with a 9 Fibonacci sequence. Example output below for a = 0, b = 1 with 10 terms. Fibonacci sequence with starting numbers [0, 1] is e 1 1 2 35 8 13 21 34 One interesting property of a Fibonacci sequence is that the ratio of the values of adj

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
A Fibonacci sequence is composed of elements created by adding the two previous elements. The simplest Fibonacci
sequence starts with 0, 1 and proceeds as follows:
0, 1, 1, 2, 3, 5, 8, 13, .
However, a Fibonacci sequence can be created with any two starting numbers (a, b).
A. Write an m-file that calculates the Fibonacci sequence (10 terms long) as a vector using a for loop with a = 5
and b = 8. Use fprintf() to output the sequence. You may want to use num2str() with a %s specifier to print the
Fibonacci sequence. Example output below for a = 0, b = 1 with 10 terms.
Fibonacci sequence with starting numbers [0, 1] is
e 1 1 2 3 5 8 13 21 34
B. One interesting property of a Fibonacci sequence is that the ratio of the values of adjacent members of the
1+5
sequence approaches a number called "golden ratio":
2
Using the same two initial numbers specified in part A, continue calculating Fibonacci terms in the sequence
until the ratio of adjacent values converges to the golden ratio within an absolute difference (error) of 10. Plot
the calculated ratios against each ratio pair number using cross markers connected with solid lines, and compare
with the exact ratio (dashed line) in the same plot. Also, use fprintf() to print the number of Fibonacci terms
required to achieve the absolute error. Example output below.
15 Fibonacci numbers needed to achieve absolute error less than 1.000000e-05
Use pen and paper to understand the process before coding this. Example calculations for the first few terms are
shown below.
Terms = 2
Fibonacci sequence [5, 8]
Ratio pair 1 = 8/5
1.6
%3D
Error = |1.6 - 5= 0.0180
Terms = 3
Fibonacci sequence = [5, 8, 13]
Ratio pair 2 = 13/8 = 1. 625
Error = |1.625 - = 0.0070
Continue until error is below 10.
Transcribed Image Text:A Fibonacci sequence is composed of elements created by adding the two previous elements. The simplest Fibonacci sequence starts with 0, 1 and proceeds as follows: 0, 1, 1, 2, 3, 5, 8, 13, . However, a Fibonacci sequence can be created with any two starting numbers (a, b). A. Write an m-file that calculates the Fibonacci sequence (10 terms long) as a vector using a for loop with a = 5 and b = 8. Use fprintf() to output the sequence. You may want to use num2str() with a %s specifier to print the Fibonacci sequence. Example output below for a = 0, b = 1 with 10 terms. Fibonacci sequence with starting numbers [0, 1] is e 1 1 2 3 5 8 13 21 34 B. One interesting property of a Fibonacci sequence is that the ratio of the values of adjacent members of the 1+5 sequence approaches a number called "golden ratio": 2 Using the same two initial numbers specified in part A, continue calculating Fibonacci terms in the sequence until the ratio of adjacent values converges to the golden ratio within an absolute difference (error) of 10. Plot the calculated ratios against each ratio pair number using cross markers connected with solid lines, and compare with the exact ratio (dashed line) in the same plot. Also, use fprintf() to print the number of Fibonacci terms required to achieve the absolute error. Example output below. 15 Fibonacci numbers needed to achieve absolute error less than 1.000000e-05 Use pen and paper to understand the process before coding this. Example calculations for the first few terms are shown below. Terms = 2 Fibonacci sequence [5, 8] Ratio pair 1 = 8/5 1.6 %3D Error = |1.6 - 5= 0.0180 Terms = 3 Fibonacci sequence = [5, 8, 13] Ratio pair 2 = 13/8 = 1. 625 Error = |1.625 - = 0.0070 Continue until error is below 10.
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY