%% House Keeping
clear all
close all
clc
 
%% Calculate velocity of water using kinematics
x_data = [36 52 63 72 79 86 93 102 107 114]; %[in] distance water traveled
Number_pumps = [1 2 3 4 5 6 7 8 9 10]; %number of pumps
h = 33.5; %[in] height of table

g = -9.81; %[m/s^2] acceleration of gravity
rho = 1000; %[kg/m^3] water density
P2 = 101000; %[Pa] atmospheric pressure

x_data = x_data.*0.0254; %[m] convert inches to meters
h = h*0.0254; %[m] convert inches to meters
 
t = sqrt((-2*h)/g); %[sec] compute time water is in the air
 
Vx = x_data./t; %[m/s] horizontal velocity of water
 
%% Calculate pressure inside squirt gun
V2 = Vx; %reassign variable
P1 = (1/2)*rho*V2.^2 + P2; % [Pa] pressure inside squirt gun
Pressure_data = P1; %reassign variable
 
%% Plot pressure inside gun versus number of pumps 
figure
plot(Number_pumps, Pressure_data)
title('Number of Pumps Versus Pressure')
xlabel('Number of Pumps')
ylabel('Pressure Inside Squirt Gun [Pa]')
 
%% Plot distance water travelled versus the number of pumps
figure
plot(Number_pumps, x_data)
title('Number of Pumps Versus Distance')
xlabel('Number of Pumps')
ylabel('Distance Water Traveled [m]')
