matlab project

nnnnooo1
timer Asked: Nov 29th, 2017

Question Description

HI,
Here are the project description.
In this project, you are to simulate the trajectories of a basketball as it is launched inside
a court. The ball, initially at rest, is thrown by an applied force, I, in the direction described
by aim angles ? and f. In flight, the motion of the ball is influenced by gravitational, drag
and Magnus forces. The Magnus force which results from spinning motion causes the trajectory
to bend. You will examine the trajectories of various shots which are launched with
different initial conditions.
The trajectories of the basketball can be described by the following equations: (I will send the equations to your email later).
The following parameters will be needed in the project:(I will send the parameters to your email later).
You are to simulate 7 different shots of the basketball. The initial conditions for each shot are given in the file input parameter.dat. In the simulation, the ball needs to stay inside the court. When the ball hits the rim (hoop) or the backboard, it stops moving. The geometry
of the court, the rim and the backboard are stored in the file court geometry.mat. Download the files: input parameter.dat and court geometry.mat from TritonED. Also, take a look at the script plot court geometry.m on TritonED to get familiar with the geometry of the court.
Using Euler-Cromer method, Equations (1) can be transformed into the following algebraic form:( I will send the equations to your email later).
For this project, you are to write three MATLAB files: basketball.m, read input.m
and project.m. The descriptions of these files are given below.
1, basketball.m: This is the function which solves Equations (2) for the projectile motion
of the basketball for a given set of parameters. Use ?t = 2×10-4
s. The function should
have the following header: function [T, X, Y, Z, U, V, W] = basketball( Xo, Yo,
Zo, Imag, theta, phi, omgX, omgY, omgZ) where the inputs and outputs are defined
above. All inputs are scalars while all outputs are vectors. In function basketball.m, you
will need to call function applied force to get instantaneous components of the applied
force needed by Equations (2). Download function applied force from TritonED.
2, read input.m: This function reads the parameters in the file input parameter.dat
into MATLAB. The function should have the following declaration: function [Xo, Yo,
Zo, Imag, theta, phi, omgX, omgY, omgZ] = read input( inputfile, shot num)
where inputfile is a string denoting the name of the file to be read and shot num is an
integer indicating the shot number. The outputs are initial position of the ball (Xo, Yo,
Zo), magnitude of the applied force (Imag), aim angles (theta, phi), and components
of rotational velocity (omgX, omgY, omgZ). When the input shot num is not available
in the file, the function should set all outputs to NaN and display an error warning to screen.
3, project.m: This script includes the results of the four tasks described below. Make
sure that both figures are plotted when your project.m is executed.
Task 1: Here, you are to simulate the seven trajectories of the basketball. Call basketball.m
to get the trajectories. For each trajectory, the outputs should include time (T),
three components of position (X, Y, Z) and three components of velocities (U, V, W), and
all of these variables should be vectors with the same length.
Task 2: Create two figures:
• Create figure 1 to plot the seven trajectories, the court, the hoop and the backboard.
Use asterisks to locate the initial positions of the ball, solid circles to locate the landing
positions, and solid lines for the trajectories. Use different colors for each trajectory.
Use function plot3. The figure should have title, legend and grid. The axes should be
labelled with units.
• Create figure 2 to include two panels, one on top of the other. The top panel shows
kinetic energy versus time, and the bottom panel shows potential energy versus time
for all seven trajectories. For each trajectory in each panel, use asterisks to mark the
times where the potential energy is equal to the kinetic energy. Use different colors for
each trajectory. Remember to include title, legend, grid, and axis label with correct
unit.
Task 3: Create a 7-element data structure named ball stat with the following fields :
• shot number: to include the trajectory number (from 1 to 7).
• time: to include the total elapsed time.
• max height position: to include a 3-element vector indicating the location (X,Y,Z)
of the max height.
• landing position: to include a 3-element vector indicating the landing location (X,
Y, Z).
• landing speed: to include the velocity magnitude at landing location.
• travel distance: to include the travel distance (arc length) along the trajectories.
Task 4: Use function fprintf to create a text file named report.txt. The text file
should include the following lines:
• Your name on the first line.
• Your PID on the second line.
• A string 'shot number, travel time (s), landing speed (m/s), travel distance
(m)' on the third line.
• Corresponding values of shot number, travel time, landing speed, and travel distance
for each of the seven trajectories from line fourth to line tenth. Use single digit for the
shot number and format %15.9e for others.
At the end of your project.m script, set the following:
p1a = 'See figure 1';
p1b = 'See figure 2';
p2a = ball stat(1);
p2b = ball stat(2);
p2c = ball stat(3);
p2d = ball stat(4);
p2e = ball stat(5);
p2f = ball stat(6);
p2g = ball stat(7);
p3 = evalc('type report.txt');
Submission instructions: Follow the homework solution template. Remember to clear
all, close all, clc, and fill in your name and PID. Set hw num = 'project'. Create a zip
archive named project.zip. The zip archive should include the following files: project.m,
basketball.m, read input.m, applied force.m, input parameter.dat, court geometry.mat
and any other scripts / functions that you have written for the project. Make sure that you
include all necessary files so that your project.m will run properly.
There are four files which are input_parameter.dat, court_geometry.mat, plot_court_geometry.m, and applied_force.m.

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors