You are on page 1of 2

Program purpose

Table of Contents
Start .................................................................................................................................. 1
Load in measured data ......................................................................................................... 1
Copy of measured data ........................................................................................................ 1
Extract & store in variables .................................................................................................. 1
Define arrays for calculations & graph ................................................................................... 1
Formula & calculation ......................................................................................................... 1
Plot measured data + calculated results on one graph ................................................................ 2
Publish code as a pdf via command window ............................................................................ 2

This program's purpose is to compare measured field data on a popular


kid's pitching machine to a claim that the machine will deliver pitches
at 30 mph that travel 30ft.
The project task then is to load in the raw data from a mat file, code a
formula that represents the claim, and then compare the two by plotting
both on the same graph.

Start
clear, clc %clear workspace & command windows

Load in measured data


load ardata

Copy of measured data


ar = rangedata;

Extract & store in variables


angles = ar(1,:); %1st row angles 15 to 85 degrees
horizd=ar(2:end,:); %horizontal distances in remaining rows and
columns
avghd=mean(horizd); %average each col of distance trials, ft

Define arrays for calculations & graph


mph=30; %mph (30 mph claimed)
Vi=1.4667*mph; %ft/s, convert mph --> fps
g=32.2; %ft/s^2, acceleration due to gravity
gen_angles = 0 : 1 : 90; %row vector contains from 0 to 90 deg angles

Formula & calculation


s=Vi^2*sind(2*gen_angles)/g; %predicted range in feet

1
Program purpose

Plot measured data + calculated results on one


graph
plot(angles,avghd,'or') %plot of measured data only
hold on %Freezes the current plot to overlay additional plots
plot(gen_angles,s) %plot of calculated values
xlabel('angles in degrees') %x-axis label
ylabel('horizontal distance in feet') %y-axis label
title('Kid''s Pitching Machine: Predicted and Measured Values')
hold off
legend('Measured distances','Predicted distances') %add a legend

Publish code as a pdf via command window


Published with MATLAB R2016a

You might also like