Answered step by step
Verified Expert Solution
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
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
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