Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

with using matlab 4. Let x, be any positive integer. Suppose that the following rules are used to generate a sequence of numbers based on

with using matlab image text in transcribed
4. Let x, be any positive integer. Suppose that the following rules are used to generate a sequence of numbers based on XI. rule O: when Xx = 1, stop. if xx is even rule : Xk+1 (3xx + 1 if Xk is odd For example, x1 = 5 generates the sequence 5 16 8 4 2 1 and x = 11 generates the sequence 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1. (a) Write a function file to implement the foregoing rules, where the generated sequence is the output value of the function. Set the file name as 'mysequence.m'. (b) Compute and display the sequence with input, X; = 9. (c) Compute the length (number of elements) of the sequence in part (b) using the command length(mysequence(9)) (d) Write for loop in a script file to call the function created in part (a) to find the lengths of the sequences generated with the inputs, x1 = 1, x1 = 2, X = 3, ... until x1 = 100. (e) Expand the script file in part (d) to plot the graph of "length of sequences versus input values, x1, for x1 = 1,2,3,.. 100

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

Formal SQL Tuning For Oracle Databases Practical Efficiency Efficient Practice

Authors: Leonid Nossov ,Hanno Ernst ,Victor Chupis

1st Edition

3662570564, 978-3662570562

More Books

Students also viewed these Databases questions

Question

=+ a. a family deciding whether to buy a new car

Answered: 1 week ago

Question

=+10. How are inflation and unemployment related in the short run?

Answered: 1 week ago