MATLAB collatz.m ○ collatzSteps.m ○ plotCollatz.m

Completed Posted 5 years ago Paid on delivery
Completed Paid on delivery

Instructions

As usual, since this is a new language, it is important to draw flow charts or write pseudo

code before writing MATLAB code. Make sure you know what you want to do before writing

any code.

Assignment 1:

Write a function file with a function collatz() which takes a positive integer and calculates

the next number in the sequence (as above) and returns it. For example collatz(5) should

return 16 .

To determine whether a number is odd or even you can not use % for the modulo operator

like in C (since the % is used for comments in MATLAB). Instead you use the

MATLAB-function mod() . To compute, for instance, 5 modulo 2, you write mod(5,2) .

Your function should not print anything in the command window, you need to suppress any

output of calculations.

Assignment 2:

Your task is now to write another function (in another function file) called collatzSteps()

which calculates, for a given number x, how many times we need to apply the

collatz()- function before we reach 1.

As an example, collatzSteps(11) should return the number 14, since it takes 14 steps to

reach 1 if we start from 11:

11 (odd) -> 34 (even) -> 17 (odd) -> 52 (even) -> 26 (even) -> 13 (odd) -> 40 (even) -> 20

(even) -> 10 (even) -> 5 (odd) -> 16 (even) -> 8 (even) -> 4 (even) -> 2 (even) -> 1

The function should not print any results of calculations, it should only return the final result.

Note that the function collatzSteps() must call the collatz() -function to compute the

result.

Assignment 3:

Finally, you should make a normal script-fil (not a function file) called “ plotCollatz.m ”

which plots the function collatzSteps() graphically. It is enough to plot the function for the

first 100 integers, in order to get an idea of how the collatz-algorithm “behaves”. Since the

collaz()-function is defined only for integers, it is important that you plot only integer points. In

other words, your x-axis list must contain only integer points.

The script should only plot the function, it may not print any calculation results.

Send the following:

● All .m-files:

○ collatz.m

○ collatzSteps.m

○ plotCollatz.m

○ A picture of the plot (take a screenshot, or save the picture. Don’t photograph

the screen). All common image formats are ok, PDF is also ok.

Algorithm C Programming C++ Programming Mathematics Matlab and Mathematica

Project ID: #18612844

About the project

12 proposals Remote project Active 5 years ago

Awarded to:

ne0ph0enix

Hi. I can help you to write the code you need in Matlab. I have experience programming in several programming languages and using numerical methods.

$25 USD in 1 day
(202 Reviews)
6.4

12 freelancers are bidding on average $37 for this job

uzairrzahid

Hi. My name is Uzair.I did my masters in Electrical Engineering. I have done my thesis in biomedical signal processing and Machine learning. I have more than 3 years of experience in Python/MATLAB specially in Machine More

$35 USD in 2 days
(67 Reviews)
6.1
MathsMasterA

Hi, I am a professional in Algebra and mathematics. If you keep in touch with me, you will get the best result from me. I am waiting for your answer. Thanks.

$60 USD in 1 day
(33 Reviews)
5.5
DianaAli0608

I can do this project. I have experience of Python, C & C++ and Java programming for 4+ years. I can satisfy you perfectly. Please contact me and discuss in detail.

$100 USD in 1 day
(11 Reviews)
3.6
sgo5884f49acdcb6

Hello I am experienced in MATLAB and have read and understood the project. I would like to work on this. Please DM me for more details. Regards Sangeeta

$25 USD in 1 day
(8 Reviews)
3.6
amuratagic

Hello Sir, I have experience working with Matlab and I can complete your project in less than 1 hour. I am new on this platform so I am looking for a great review and I can assure you I will complete your project very More

$20 USD in 1 day
(2 Reviews)
2.3
TheAnsari97

I'm an Electrical Engineer with good knowledge and programming experience in MATLAB and other programming languages such as C++, Python. I can do this work for you with ease and with perfection. We can discuss further More

$25 USD in 1 day
(6 Reviews)
2.0
Dushyanthik

Hi, I m a graduate student recently joined freelencer. I can help you with this matlab task. I can send you the necessary script files within 1 day. I have good understanding about the task. For the task 1 it is sim More

$25 USD in 1 day
(2 Reviews)
2.2
nithinbanka

Hi, I have 2+ years of experience in MATLAB abd I am very familiar with the tasks you have mentioned. I can complete the task within given time. This is an easy task and shouldn't take more time. Please message me More

$25 USD in 2 days
(1 Review)
0.7
cj23897

Hey I am good in Matlab and currently working at MathWorks hence would be able to help you with the project. Relevant Skills and Experience I have intermediate experience in coding in MATLAB. Currently working in Math More

$35 USD in 2 days
(0 Reviews)
0.0