Question
1. Write a function called RandomPetName. There are no inputs to this function. The function will return a randomly chosen string from the following list:
1. Write a function called RandomPetName. There are no inputs to this function. The function will return a randomly chosen string from the following list: "Fluffy", "Coco", "Simba", "Shadow", "Kitkat", "Tigger", "Princess", "Max", "Milo", "Bella", "Rocky", "Baxter".
Hint: Inside the function, create a vector, not containing numbers, but instead containing all the strings listed above. There are twelve of them. So how do you tell Matlab to randomly choose one element from a 1x12 vector? It would help if you had a random integer from 1 to 12...
2. Write a function called EvenPart. This function must be recursive (it calls itself within its own code). The input to this function is a single number, n. The funciton will return the largest power of 2 that is a divisor of n. So for example, EvenPart(12) = 4 because 4 is a divisor of 12 but 8 is not. Also EvenPart(7) = 1 because even 2 is not a divisor of 7.
Math Lab homework, please help thank you so much
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started