Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please fix this code to work properly with the requirements shown in Matlab grader. the last picture is showing issues I'm getting Iterative Fibonacci (scalar
Please fix this code to work properly with the requirements shown in Matlab grader. the last picture is showing issues I'm getting
Iterative Fibonacci (scalar output) 9 solutions submitted (max: Unlimited) | View my solutions The Fibonacci sequence defined by F=1,1,2,3,5,8,13,21,34,55,89 where the kth term is given by Fk=Ek1+Fk2 Code has already been provided to define a function named fibGenerat or that accepts a single input value into the variable N. Add code to the function th output variable fib. Assume the input N will always be greater than or equal to 3 , so first generate an array of ones, then stant the lonp from the 3rd term Note the value of N is defined as an input to the funciton, Do not overwrite this value in your code. Be sure to assign values to each - 1 the function output val Use a for loop in your solution. Function function fib = fibGenerator (N) \% Initialize the Fibonacci sequence with the first two values fib =ones(1,N); \% Generate the Fibonacci sequence starting from the 3 rd term for i=3:N fib(i)=fib(i1)+fib(i2); end end Code to call your function B Previous Assessment: 1 of 4 Tests Passed Is the value assigned to fib correct for N=5 ? (Pretest) Variable fib must be of size [ 11 1] It is currently of size [ 15 . 5]. Check where the variable is assigned a va Is the value assigned to fib correct for N=10 ? (Pretest) Is the value assigned to fib correct for a hidden value of N greater than 20 ? antable fib must be of size [1 1]. It is currently of size [1 29]. Check where the variable is assigned a valu Does solution use a for loop? (Pretest) N. Add code to the function that uses a for loop to generate the Nth term in the sequence and assign this value to the art the loop fram the 3 rd term. to each of the function output variablesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started