Question

MATLAB Grader CONTENTS For this problem you will model a field goal attempt in an NFL football game as a simple projectile mo
MATLAB Grader CONTENTS Write a function named fieldGoal that computes whether or not a given initial velocity and angle is su
MATLAB Grader CONTENTS The function should return the following two outputs (in order) 1. A column vector of the vertical dis
MATLAB Grader CONTENTS For this problem you will model a field goal attempt in an NFL football game as a simple projectile motion problem. For a field goal attempt, the ball is snapped seven yards back from the line of scrimmage, where the place holder holds the ball on the ground for the kicker. For a successful attempt, the kicker must kick the ball through the uprights above the cross bar, which is ten feet high and parallel to the back of the end zone. See goals. The formula for the trajectory (height, y versus distance, x) of a projectile can be derived from physics and is: 2 (vo cos ) where y is the height in feet, x is the horizontal position in feet, θ is the initial angle, g is the acceleration due to gravity (32.2 ft/s2), vo is the initial velocity in feet/second, and yo is the initial height in feet. To model a field goal kick, we will take yo-0 since the ball is kicked off the ground.
MATLAB Grader CONTENTS Write a function named fieldGoal that computes whether or not a given initial velocity and angle is successful (i.e. is the ball higher than the cross bar when it reaches the back of the end zone?). Your function should accept the following three inputs (in order) 1. A vector of one or more yard lines from which the attempt is made. Note that you must add 17 yards to this input to get the required distance of the field goal attempt. This addition accounts for a 7-yard snap and the 10-yard depth of the end zone. Remember the formula above requires distance in feet (1 yard 3 feet) 2. A vector of one or more initial velocities for the kick, each element corresponding to the yard line of each attempt in the first input vector 3. A scalar that gives the initial angle 0 of the kick trajectory in degrees The function should return the following two outputs (in order) 1. A column vector of the vertical distance (in feet) by which the kick cleared the 10-foot high crossbar. If the kick was unsuccessful, then the corresponding element in this output should be negative
MATLAB Grader CONTENTS The function should return the following two outputs (in order) 1. A column vector of the vertical distance (in feet) by which the kick cleared the 10-foot high crossbar. If the kick was unsuccessful, then the corresponding element in this output should be negative 2. A column vector of the points awarded (3, 1, or 0) for each of the attempts in the input vectors. A successful attempt is 3 points unless it is from the 15-yard line. If from the 15 yard line a successful attempt is considered an "extra point" and awarded 1 point. Unsuccessful attempts earn O points Also, if the number of elements in the first two input variables is not equal (i.e. the function is not given an initial velocity for each yard line attempt) then both outputs should equal 999 to indicate the input error Your function will pass the first two test cases if it works only for scalar input variables, so you may want to make sure you get that working before modifying the function to work for vector inputs so it will pass the last three test cases Note the function command is given in line 1 with suggested names for the input and output variables. You can change the names (but not the order) of these variables if you like. Do not change the name of the function
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Given that

we have to write the MATLAB code to the given problem

MATLAB CODE:

function [y,allScores] = fieldGoal(x,v0,theta)

pointsSuccess = 3;
feetsInYard = 3;

g = 32.2; %ft/s^2
y0 = 0; % from ground
crossBarHeight = 10; %feet

f = @(x,v0,theta) x.*tan(theta) - (x.^2.*g)./(2.*(v0.*cos(theta)).^2) + y0;

theta = theta*pi/180; % to radians


x = (17+ x); %in yards

x = x.*feetsInYard; % to feet

y = f(x,v0,theta); %computing verticle distance y


allScores = zeros(1,numel(y));

%goal
goalIndices = find(y>crossBarHeight);
numberOfSucessPoints = numel(goalIndices);
successScores = ones(1,numberOfSucessPoints).*pointsSuccess;

feetAtGoalIndices = y(goalIndices);
yardsAtGoalIndices = feetAtGoalIndices./feetsInYard; % to yards

onePointIndices = find(yardsAtGoalIndices==15); %

successScores(onePointIndices) = 1;

allScores(goalIndices) = successScores;

end

--------------------------------------------------------------

%driver file

clc
clear
close all

v0 = linspace(1,80,10) %feet/s
%x = linspace(0,30,10) % feet
x = 30% feet
theta = 45 %degrees

[y,pointsAwarded] = fieldGoal(x,v0,theta)

vo = 1.0000 9.7778 18.5556 27.3333 36.1111 44.8889 53 .6667 62-4444 71-2222 80.0ננ theta 45 30 y- 1.0e+05* -6.4003 0.0655 0.0

1.0000 9.7778 18.5556 27.3333 36.1111 44.8889 53.6667 62.4444 71.2222 80.0000 ,331001,3r 10.00 23,33 5 4030.00 6.6667 10.0000

Add a comment
Know the answer?
Add Answer to:
MATLAB Grader CONTENTS For this problem you will model a field goal attempt in an NFL football ga...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (Please show all work) Suppose a field goal kicker (American football) can kick the ball at...

    (Please show all work) Suppose a field goal kicker (American football) can kick the ball at a launch speed of 58 miles/hour. If the ball is placed at the 50-yard line, he is actually kicking the ball 60 yards to the goal post. Additionally, the crossbar is 10 feet above the ground. (1 mile = 5280 ft = 1760 yds = 1609.3 m) A. Convert all distances to SI units; all answers will thus be in SI units. B. Show...

  • The Saint Louis Rams nearly lost a play-off game after field-goal kicker Jeff Wilkins sent a...

    The Saint Louis Rams nearly lost a play-off game after field-goal kicker Jeff Wilkins sent a 132 ft. field-goal attempt (that is, he kicked the ball from the 34 yard-line) straight into the goal-post cross-bar, which is 10 ft. above the ground. He kicked the 2 lb. ball at an angle of a = 30°. 10 feet 132 feet- Treat the ball as a point mass, and neglect wind resistance. (a) (20 pts) What is the velocity v, with which...

  • The Green Monster, as shown below, is a wall 37 feet high in left field at...

    The Green Monster, as shown below, is a wall 37 feet high in left field at Fenway Park in Boston. The wall is 310 feet from home plate down the third base line. If the batter hits the ball 4 feet above the ground, neglecting air resistance, determine the minimum speed that the bat must impart to the ball that is hit over the Green Monster. COVIDIE CVS. ELABOR The equations of motions for the baseball are x(t) = (u...

  • Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be...

    Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book tit le, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an...

  • Don't attempt if you can't attempt fully, i will dislike and negative comments would be given...

    Don't attempt if you can't attempt fully, i will dislike and negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book titnle, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an HTML web...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT