Question: Create a User Defined fuction in Matlab regarding the following problem statement using loops or if statments Problem Setup The Collatz Conjecture is a famous

Create a User Defined fuction in Matlab regarding the following problem statement

using loops or if statments

Create a User Defined fuction in Matlab regarding the following problem statement

Problem Setup The Collatz Conjecture is a famous mathematical problem thatwas first presented in 1930s. Itis straightforward to understand butremains unproven. The problem states that you cancreate a sequence from any positive integer thatwill eventually end in 1 byfollowing this process Select a positiveinteger Ifthatinteger is even, divide it by 2, butifitisodd, then multiplyit by 3 and then add 1 Repeatthis process on each result until youreach 1 0 An integer's Collatz sequence is the list of numbers thatare created by this process. For example, the sequence for 6 is THE COLLATZ CONJECTURE STATES THAT IFYOU ThO AND IF ITS ODD MULTIPLY IT BY THREE AND ADD ONE, AND YOU REPEAT THIS PROCEDURE LONG ENOUGH, EVENTURLLY YOUR FRIENDS WAL STOP CALLING TO SEE IF YOU WANT TO HANG OUT 6,3,10,5,16,8,4,2,1 This sequence has eight steps (i.e., number of calculations to reach1) You arean engineer who works for a STEM (Science, Technology, Engineering, and Mathematics)education firm. Your group is designing algebra educational apps and wants to include a game based on the Collatz Conjecture. Your task is to create a user-defined function to create a vector of sequential positive integers andthen build a second vectorthatcontains the number of Collatz-sequence steps for eachinteger in thefirst vector. Your user- defined function must: Accept as input arguments the initial positive integer andthetotal number of integers inthe sequential vector Createthe vector of sequenti al integers thatstarts with the initial positive integer input andincrements by 1 until thevector has the total number of elements, including the initial integer, thatwas set in the inputarguments For each elementin the integer vector, determine the number of Collatz-sequence steps and store that informationin another vector Plotthenumber of steps versus theinteger values. Format the plot fortechnical presentation, including a reference to thefirstand lastintegers in the integers vector . Return as output arguments the vector of integers and the vector of corresponding steps. Learn about the fol lowing built-in MATLAB commands, which might be useful in your solution rem, num2str

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!