Question
% Initialization clear % clears base workspace hold on; % allows successive plotting in one plot batAngle = 45; % optimum swing angle heightGreenMonster =
% Initialization clear % clears base workspace hold on; % allows successive plotting in one plot batAngle = 45; % optimum swing angle heightGreenMonster = 11.3; % height of Green Monster wall distanceGreenMonster = 96; % distance of Green Monster wall heightSwing = 1.0; % swing height of batter in meters
% Special plot function to show batter and wall heights stem([0,distanceGreenMonster],[heightSwing,heightGreenMonster],.... "MarkerFaceColor","green"); ballVelocity=20; % velocity of ball = 20 m/sec [ x, y] = Trajectory(batAngle, ballVelocity); y = heightSwing + y; % adjust vertical with batters swing height ProcessData(x, y);
ballVelocity=25; % velocity of ball = 25 m/sec [ x, y] = Trajectory(batAngle, ballVeelocity); ProcessData(x, heightSwing + y);
ballVelocity=30; % velocity of ball = 30 m/sec [ x, y] = Trajectory(batAngle, ballVelocity); ProcessData(x, heightSwing + y);
ballVelocity=32.5; % velocity of ball = 32.5 m/sec [ x, y] = Trajectory(batAngle,ballVelocity ); ProcessData(x, heightSwing + y); hold off
function [ x, y] = Trajectory(batAngle, ballVelocity) % Trajectory Calculation gravity = 9.8; tFlight = (2 * ballVelocity * sind(batAngle)) / gravity; time = linspace(0, tFlight, 1000);
x = ballVelocity * cosd(batAngle) * time; y = (ballVelocity * sind(batAngle) * time)... - ((gravity * (time.^2))/ 2); end
function Process_Data(batAngle, ballVelocity, x, y) % Process Data gravity = 9.8; xMax = max(x); yMax = max(y); figure(1); plot(x,y); axis([0, 1.1*xMax, 0, 1.1*yMax]); xlabel("Distance in meters"); ylabel("Height in meters") end
function Trajectory_and_Process(batAngle, ballVelocity) % Calculate trajectory [x, y] = Trajectory(batAngle, ballVelocity); % Process Data Process_Data(batAngle, ballVelocity, x, y); end
- Re-write this Live script to determine what ball speed is required to clear the Green Monster. Correct script errors and make it run.
- This is run in matlab
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