Question: matlab question Use a for loop and conditionals (if or switch) to creates a Fibonacci matrix, defined as follows. The Fibonacci matrix is constructed by
Use a for loop and conditionals (if or switch) to creates a Fibonacci matrix, defined as follows. The Fibonacci matrix is constructed by starting with the matrix (1 1) and repeatedly concatenating a square matrix whose size in each dimension, and values, correspond to the size of the longest edge of the current matrix. Matrices are concatenated in counterclockwise order, starting by concatenating a 2 by 2 matrix of 2s to the top of (1 1]. See below for a Fibonacci matrix with 8 as its largest number: 3 3 3 2 2 8 8 8 8 8 8 8 8 3 3 3 2 2 8 8 8 8 8 8 8 8 3 3 3 1 1 8 8 8 8 8 8 8 8 5 5 5 5 5 8 8 8 8 8 8 8 8 5 5 5 5 5 8 8 8 8 8 8 8 8 5 5 5 5 5 8 8 8 8 8 8 8 8 5 5 5 5 5 8 8 8 8 8 8 8 8 5 5 5 5 5 8 8 8 8 8 8 8 8 The color-coding above is simply a visual aid for demonstrating the structure of the matrix; you don't need to color-code your solution (and I don't know how you would...) Use your loop to create a Fibonacci matrix with 4181 as its largest value; that is, the final result should be a 6765 (the next Fibonacci) by 4181 matrix with the number 4181 as its largest value. Store this matrix as fib4181 (3 points). HINT: A common question is "how do I alternate which side I'm concatenating on?" That's what you should use the conditional for. One way to do this is to make a condition that cycles through the same four values and determine the side of concatenation from those values. There are many ways to do this; for example, the mod function can be helpful, or you can create an additional "counter" variable. HINT: Feel free to adapt the code to generate Fibonacci numbers from W3D1 slide 23. 4181 is the 19th Fibonacci number, but it is not necessary to calculate it directly in order to solve this
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
