Consider the motion of an object modeled with ideal projectile motion (neglecting air resistance). y=xtan 0- d= The trajectory of the object can be derived from basic physics and is given by the formula: 1 x²g 2 (Vo cos 0)² + Yo Vocos ( 8 Yo V (vo sin 0 + √(vo sin 0)² + 2gyo) V 0 where y is the height in meters, x is the horizontal position in meters, is the initial angle, g is the acceleration due to gravity (9.81m/s²), vo is the initial elocity in m/s, and yo is the initial height in meters. The range, d, of the projectile is the total horizontal distance it travels before hitting the ground and can be determined using the formula: d Code has already been provided to define a function named projectileTrajectory that accepts values for vo (units of meters/second), 0 (units of degrees), and yo (units of meters) as inputs and assigns them to the variables ve, theta, and yo respectively. Add commands to compute the following and assign to the indicated output variables. ▪ Generate a column vector of 200 equally-spaced x-values starting at 0 and ending at d and assign to the output variable x. ▪ Generate a column vector of 200 y-values that gives the height of the projectile corresponding to each x in the fist output and assign to the output variable y. ▪ Determine the coordinates (x, y) of the peak of the trajectory (i.e. the highest value of y and the corresponding value of x) and assign as a 2-element row vector to the variable xyPeak. Solve this problem using only vectorized code with no loops or if statements. Note the values of ve, theta, and ye are supplied to the function when it is run by MATLAB grader. Be sure not to overwrite these values in your code. Function > Save C Reset MATLAB Documentation

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter1: Fundamentals Of C++ Programming
Section: Chapter Questions
Problem 2PP: (Conversion) An object’s polar moment of inertia, J, represents its resistance to twisting. For a...
icon
Related questions
Question

Use vectorized code free of for, while, and if commands

Consider the motion of an object modeled with ideal projectile motion (neglecting air resistance).
y = xtan 0-1
d =
The trajectory of the object can be derived from basic physics and is given by the formula:
x²g
2 (Vo cos 0)²
Vocos (
8
+ Yo
(vo sin 0 + √(vo sin 0)² + 2gyo)
Yo
where y is the height in meters, x is the horizontal position in meters, is the initial angle, g is the acceleration due to gravity (9.81m/s²), vo is the
initial velocity in m/s, and yo is the initial height in meters. The range, d, of the projectile is the total horizontal distance it travels before hitting the
ground and can be determined using the formula:
V
0
Code has already been provided to define a function named projectileTrajectory that accepts values for vo (units of meters/second), 0 (units
of degrees), and yo (units of meters) as inputs and assigns them to the variables vê, theta, and yo respectively. Add commands to compute the
following and assign to the indicated output variables.
▪ Generate a column vector of 200 equally-spaced x-values starting at 0 and ending at d and assign to the output variable x.
▪ Generate a column vector of 200 y-values that gives the height of the projectile corresponding to each x in the fist output and assign to the
output variable y.
Code to call your function >
d
▪ Determine the coordinates (x, y) of the peak of the trajectory (i.e. the highest value of y and the corresponding value of x) and assign as a
2-element row vector to the variable xyPeak.
Assessment:
Solve this problem using only vectorized code with no loops or if statements. Note the values of ve, theta, and ye are supplied to the function
when it is run by MATLAB grader. Be sure not to overwrite these values in your code.
Function >
1 [x, y, xyPeak] = projectileTrajectory (20, 35, 5)
1 function [x, y, xyPeak] = projectileTrajectory( vė, theta, ye )
2 %Enter the commands for your function in the space below. Use the variable names specified in
3 %the function definition command in line 1. Be sure to assign values to each of the output variables.
4
Is first output x correct for inputs (20, 35, 5)? (Pretest)
>
Is second output y correct for inputs (20, 35, 5)? (Pretest)
>
Is third output xyPeak correct for inputs (20, 35, 5)? (Pretest)
Are all three outputs correct for new input values?
Save
C Reset
> Does solution use vectorized code free of for, while, and if commands? (Pretest)
MATLAB Documentation
C Reset
Transcribed Image Text:Consider the motion of an object modeled with ideal projectile motion (neglecting air resistance). y = xtan 0-1 d = The trajectory of the object can be derived from basic physics and is given by the formula: x²g 2 (Vo cos 0)² Vocos ( 8 + Yo (vo sin 0 + √(vo sin 0)² + 2gyo) Yo where y is the height in meters, x is the horizontal position in meters, is the initial angle, g is the acceleration due to gravity (9.81m/s²), vo is the initial velocity in m/s, and yo is the initial height in meters. The range, d, of the projectile is the total horizontal distance it travels before hitting the ground and can be determined using the formula: V 0 Code has already been provided to define a function named projectileTrajectory that accepts values for vo (units of meters/second), 0 (units of degrees), and yo (units of meters) as inputs and assigns them to the variables vê, theta, and yo respectively. Add commands to compute the following and assign to the indicated output variables. ▪ Generate a column vector of 200 equally-spaced x-values starting at 0 and ending at d and assign to the output variable x. ▪ Generate a column vector of 200 y-values that gives the height of the projectile corresponding to each x in the fist output and assign to the output variable y. Code to call your function > d ▪ Determine the coordinates (x, y) of the peak of the trajectory (i.e. the highest value of y and the corresponding value of x) and assign as a 2-element row vector to the variable xyPeak. Assessment: Solve this problem using only vectorized code with no loops or if statements. Note the values of ve, theta, and ye are supplied to the function when it is run by MATLAB grader. Be sure not to overwrite these values in your code. Function > 1 [x, y, xyPeak] = projectileTrajectory (20, 35, 5) 1 function [x, y, xyPeak] = projectileTrajectory( vė, theta, ye ) 2 %Enter the commands for your function in the space below. Use the variable names specified in 3 %the function definition command in line 1. Be sure to assign values to each of the output variables. 4 Is first output x correct for inputs (20, 35, 5)? (Pretest) > Is second output y correct for inputs (20, 35, 5)? (Pretest) > Is third output xyPeak correct for inputs (20, 35, 5)? (Pretest) Are all three outputs correct for new input values? Save C Reset > Does solution use vectorized code free of for, while, and if commands? (Pretest) MATLAB Documentation C Reset
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr