Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB PROBLEM Function Name: passIton Inputs: 1. (double) A MxN array representing a hockey rink Outputs: 1. (char) A string describing your play and its

MATLAB PROBLEM

image text in transcribed

image text in transcribed

image text in transcribed

Function Name: passIton Inputs: 1. (double) A MxN array representing a hockey rink Outputs: 1. (char) A string describing your play and its chance of success Topics: (conditionals), (indexing), (masking), (arrays) Background: The year is 2021 and the International Ice Hockey Federation has just released its new set of rules regarding the number of players each team is allowed to bring to the rink. To spice the game up a bit, the Federation has determined that one team will be allowed an unlimited number of players on the rink at the same time, while the other team is limited to just two. To ensure fairness, however, they have determined that the disadvantaged team will gain access to a wonderful tool for determining how likely the team is to succeed on any given play. That tool: MATLAB! Function Description: You are given an array of doubles representing the hockey rink, which is structured as follows: . . Zeros represent empty spots You are represented by the number 10 Your teammate is represented by a positive integer Players on the opposite team are represented by negative integers . The only two players on your team are yourself and the teammate represented by the other positive integer, but there are an undetermined number of players on the rink from the opposite team. It is your job to build a string describing how you intend to pass the puck to your teammate, and the chance of the pass succeeding. To do this, follow these steps: 1. Using your and your teammate's positions, determine the direction you will be passing the puck. If your teammate is directly above, below, to the right, or to the left of you in the array, the direction will be 'north', 'south', 'east', or 'west' respectively. If they are not located in the same row or column as you, the direction would be 'northeast', 'northwest', 'southeast', or 'southwest'. 2. Index out the subarray whose corners are the positions of you and your teammate. For example: 0 0 [0 0 0 8 0 0 0 [ 0 0 0 0 0 0 0 0 0 8 0 0-5 0 0 0 0 0 -6 0 0 10 0 0 0 0 0 0 0-4 -5 0 0-6 0 0 0 0 10 0 0 0] 0] The sum of all the positive integers in this subarray will represent your team's cumulative rating. The absolute value of the sum of all the negative integers in the subarray will represent the opposing team's cumulative rating. In this example, your team has a rating of 18 and the opposing team has a rating of 11. 3. Output the final string as follows: . . If your team's cumulative rating is higher than the opposing team's cumulative rating by 10 or more, output: 'I shot the puck to the with guaranteed success.' If your team's cumulative rating is higher than the opposing team's cumulative rating by less than 10, multiply the difference in rating by 10 to determine your chance of success as a percentage. Output: 'I shot the puck to the % chance of success.' If your team's cumulative rating is equal to or lower than the opposing team's rating, output: 'I chose not to shoot the puck to the .' Example: 0 0 0 0 0 hockeyRink = [ 0 0 0 0 0 8 0 0 0 0 0 -5 0 0 0-6 0 0 0 0 10 0 0 0 0 0 0 0 0 -4 0] play = passIton (hockeyRink) play - 'I shot the puck to the northeast with a 70% chance of success." Notes: You are guaranteed to have at least one player of the opposing team in the subarray. It does not matter if there is an opposing player between you and your teammate, the probability of the shot is only determined by the difference in teams' cumulative ratings. Your teammate's number is guaranteed to not equal 10. Similar to apostrophes in strings, use a double percent sign ('100%%' 100%) to get a percent sign in a string

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

1. Who will you assemble on the team?

Answered: 1 week ago

Question

Did the team members feel that their work mattered

Answered: 1 week ago