Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is matlab. I would greatly appreciate it if you satisfied all the assessments. The code is below but it does not satisfy all the

this is matlab. I would greatly appreciate it if you satisfied all the assessments. The code is below but it does not satisfy all the assessments. I need u to fix the code so all the assessments are satisfied.

image text in transcribed

image text in transcribed

image text in transcribed

* The reciprocal Fibonacci constant 1 solution submitted (max: 2) View my solutions The reciprocal Fibonacci constant is defined by the infinite sum: Pa 1 NETF where F, are the Fibonacci numbers 1, 1, 2, 3, 5, 8, 13, ... . Each element in this sequence of numbers is the sum of the previous two. Start by setting the first two elements equal to 1, then F, = F,-1+F,-2. Write a MATLAB program that calculates P for a given N while storing intermediate P values for a couple of selected n values. Add your code to the function reciprocalFibonacci that uses the values in n to create a vector variable named P. Note the values in n are defined as an input to the function. Do not overwrite these values in your code. Be sure to assign values to the function output variable P. Check if your sums (P) for some iteration numbers (n) are the same as: P = 3.03333 at n = 5 P = 3.33047 at n = 10 P = 3.35989 at n = 100 Function C Reset MATLAB Documer function P = reciprocalFibonacci(n) 2 *This function takes a vector of selected iteration numbers to store the calculation results. 3 %The last value in the input vector is the maximum iteration number of the loop. 4 n = [5, 10, 15, 50, 100); 5 P = reciprocalFibonacci(n); 6 display(); function P = reciprocalFibonacci(n) 8 P = []; 9 f1 = 1; 10 f2 = 1; 11 sum = 1; 12 for i = 1:n(end) 13 if n(1) == i 14 P = (P, sum); 15 n = n(2:end); 16 end 17 f = f1+f2; 18 f1 = f2; 19 f2 = f; 20 sum = sum + 1/f1; 21 end 22 end 23 end Code to call your function c iterations = [5 10 15 50 100); 2 rFibo_out = reciprocal Fibonacci (iterations); Previous Assessment: 1 of 2 Tests Passed Run Pretest Submit (Attempt 2 of 2) Is output accurate for input? (Pretest) X is output accurate for input that are different than those shown in the "Code to call your function" box? Variable rFibo_out must be of size [1 7]. It is currently of size [1 5]. Check where the variable is assigned a value. If your function passed the first test but not this one, it may be because you hard coded the numbers from the "Code to call your function" example into your code instead of using the function input variable n

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago