Question: ENGR 1202 Spring 2019 MATLAB Homework #4 Instructions: Solve the following problems in a MATLAB script. You will be allowed to submit only one script,
ENGR 1202 Spring 2019 MATLAB
Homework #4
Instructions:
- Solve the following problems in a MATLAB script. You will be allowed to submit only one script, please work all the problems in the same script (Hint: careful with variables names)
- Show your work and make comments in the same script (Use %). Please refer to formatting files previously announced/discussed.
Problem 3: A friend of the family asks you to babysit their 5-year-old named Boba Fett. After the kids tablet runs out of battery and is almost at the point to start screaming, you decide to play a game. Since you are an expert in MATLAB or at least love writing some easy scripts, you decide to work up a game for him. You want MATLAB to generate a random integer number that Boba Fett will guess.
Expected from this program:
- Generate a random integer (no higher than 35).
- Ask the user to input a guess. Please specify how high the guess could be.
- Check the guess given for the user. If the guess is too low tell the user to try again because the guess was too low. Please use the kids name. Do the same if the guess is too high.
- When the guess is equal to the random number please congratulate Boba Fett.
- If you can add sounds to the game, Boba Fett will be more eager to play over and over again which will give you time to watch one episode of the Big Bang Theory. Plus you can get bonus points.
Example:
Please enter your guess between 1 and 20: 5
Sorry your guess is too low
Please enter your next guess: 15
Sorry your guess is too high
Please enter your next guess: 5
Sorry your guess is too low
Please enter your next guess: 10 Sorry your guess is too low
Please enter your next guess: 12 Sorry your guess is too low
Please enter your next guess: 14 Sorry your guess is too high
Please enter your next guess: 13
At last! :)
Problem 4: Using loops, create a N X N box where the user specifies N. The user must input the N value. The maximum number of N will be 25.
Example: For N = 2
***
* *
***
Problem 5: For the arrays x and y given below, use MATLAB to find all the elements in x that are greater than the corresponding elements in y.
- x = [-3, 0, 0, 2, 6, 8]
- y = [-5, -2, 0, 3, 4, 10]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
