MATLAB collatz.m ○ collatzSteps.m ○ plotCollatz.m
$10-30 USD
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.
Project ID: #18612844
About the project
Awarded to:
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.
12 freelancers are bidding on average $37 for this job
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
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.
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.
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
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
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
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
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