Question: This needs to be done in Matlab Code. P#2. Sequence. Suppose we select some initial number X and then build the sequence of values by

This needs to be done in Matlab Code.

This needs to be done in Matlab Code. P#2. Sequence. Suppose we

P#2. Sequence. Suppose we select some initial number X and then build the sequence of values by the following rules i-1 for 3X-1 +1 forXi-1 odd If X._1 is odd, the next element in the sequence grows, and if it is even, the next element in the sequence decreases. For example, with the starting X- 17 we have the sequence: 17 52 26 13 40 20 10 5 16 842 1 After the sequence reaches 1 it enters the infinite loop 1 4 2 142 1... Your task is for given numbers to calculate how many steps are necessary to come to 1. For the starting X- 17, the number of steps to get to 1 is 12 (i.e., one less the number of sequence elements) Starting value, Number of Steps to reach one 0 0 2,1 3,10, 5,16, 8, 4, 2,1 4,2,1 5, 16, 8, 4,2,1 6, 3,10, 5,16, 8,4, 2,1 4 6 Write code to compute the elements of the sequence for starting values from 1 to 50. Make a plot of the starting value versus the number of steps required to reach 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!