Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions