This commit is contained in:
Aidan Sharpe 2025-02-14 22:27:10 -05:00
parent d9cec13c2e
commit 82b435b6a2
39 changed files with 867 additions and 0 deletions

View File

@ -0,0 +1,37 @@
---
title: Vocabulary Assignment 3
author: Aidan Sharpe
date: February 20th, 2025
geometry: margin=1in
---
## Atoms
An atom is the smallest elemental particle that retains it's chemical properties.
## Molecules
Two or more atoms chemically bonded, creating a new material with unique chemical properties.
## Organelles
Functional structures within biological cells.
## Cells
The smallest functional unit of life.
## Tissues
A structure comprised of cells of the same type that performs a specific function.
## Organs
A structure comprised of tissues that fulfill a task within an organ system.
## Organ systems
A collection of organs that perform a similar task.
## Body membranes
A biological barrier that lines organs and cavities.
## Interstitial fluids
Bodily fluids that exist between, as opposed to within, cells.
## Homeostasis
The tendency for living organisms to maintain a stable internal environment.

View File

@ -0,0 +1,23 @@
% Lab 2
% Question 2 on periodicity
% Define the samples axis (0 to 50, including 50)
n=0:1:50;
% Define four cosines at different frequencies
x1=cos(2*pi*n/7);
x2=cos(2*pi*n/21);
x3=cos(2*pi*n/17.5);
x4=cos(2*n/7);
% Plot each of the cosines in a separate subplot
subplot(411)
stem(n,x1,'linewidth',2)
subplot(412)
stem(n,x2,'linewidth',2)
subplot(413)
stem(n,x3,'linewidth',2)
subplot(414)
stem(n,x4,'linewidth',2)
xlabel('n');

View File

@ -0,0 +1,44 @@
import numpy as np
import matplotlib.pyplot as plt
def main():
# Define the samples axis (0 to 51, excluding 51)
n = np.arange(51)
# Define the four frequencies used
f_1 = 1/7
f_2 = 1/21
f_3 = 1/17.5
f_4 = 1/(7*np.pi)
# Convert frequencies to angular frequency
omega_1 = 2*np.pi*f_1
omega_2 = 2*np.pi*f_2
omega_3 = 2*np.pi*f_3
omega_4 = 2*np.pi*f_4
# Sample a cosine of each of the
x_1 = np.cos(omega_1*n)
x_2 = np.cos(omega_2*n)
x_3 = np.cos(omega_3*n)
x_4 = np.cos(omega_4*n)
# Plot each of the cosines in a separate subplot
plt.subplot(411)
plt.stem(n, x_1)
plt.subplot(412)
plt.stem(n, x_2)
plt.subplot(413)
plt.stem(n, x_3)
plt.subplot(414)
plt.stem(n, x_4)
plt.xlabel("n")
plt.show()
if __name__ == "__main__":
main()

View File

@ -0,0 +1,56 @@
clear x
n=0:1:12;
x(n+1)=0;
x(6)=1;
x(9)=-2;
x(12)=6;
figure(1)
stem(n,x,'linewidth',2)
xlabel('n');
ylabel('x(n)');
clear x
n=0:1:15;
x(n+1)=0;
for m=0:15
if (m < 3)
x(m+1) = 0;
elseif (m >=3 && m < 8)
x(m+1) = 1;
elseif (m >= 8 && m < 12)
x(m+1) = -1;
end
end
figure(2)
stem(n,x,'linewidth',2)
xlabel('n');
ylabel('x(n)');
clear x
n=0:1:20;
x(n+1)=n;
figure(3)
stem(n,x,'linewidth',2)
xlabel('n');
ylabel('x(n)');
clear x
n=0:1:10;
x(1)=0;
for m=1:10
x(m+1)=m*m;
end
figure(4)
stem(n,x,'linewidth',2)
xlabel('n');
ylabel('x(n)');
clear x
n=0:1:30;
for m=0:30
x(m+1)=3*(m-3)*(m-3)*exp(-0.3*m)*sin(2*m/3);
end
figure(5)
stem(n,x,'linewidth',2)
xlabel('n');
ylabel('x(n)');

View File

@ -0,0 +1,56 @@
import numpy as np
import matplotlib.pyplot as plt
def delta(n):
return np.where(n==0, 1, 0)
def u(n):
return np.heaviside(n, 1)
def main():
# Part a
n = np.arange(13)
x = delta(n-5) - 2*delta(n-8) + 6*delta(n-11)
plt.stem(n, x)
plt.xlabel("$n$")
plt.ylabel(r"$x[n] = \delta(n-5) - 2\delta(n-8) + 6\delta(n-11)$")
plt.show()
# Part b
n = np.arange(16)
x = u(n-3) - 2*u(n-8) + u(n-12)
plt.stem(n, x)
plt.xlabel("$n$")
plt.ylabel("$x[n] = u(n-3) - 2u(n-8) + u(n-12)$")
plt.show()
# Part c
n = np.arange(21)
x = n*u(n)
plt.stem(n, x)
plt.xlabel("$n$")
plt.ylabel("$x[n] = n u(n)$")
plt.show()
# Part d
n = np.arange(11)
x = n**2 * u(n)
plt.stem(n, x)
plt.xlabel(r"$n$")
plt.ylabel(r"$x[n] = n^2 u(n)$")
plt.show()
# Part e
n = np.arange(31)
x = 3 * (n-3)**2 * np.exp(-0.3*n) * np.sin(2*n/3) * u(n)
plt.stem(n, x)
plt.xlabel("$n$")
plt.ylabel(r"$x[n] = 3(n-3)^2 e^{-0.3n} \sin(2n/3) u(n)$")
plt.show()
if __name__ == "__main__":
main()

View File

@ -0,0 +1,20 @@
clear x
a=pi/4;
n=0:1:50;
x(n+1)=5*cos(a*a*n);
figure(1)
stem(n,x,'linewidth',2)
xlabel('n');
ylabel('x(n)');
clear x
a=5;
c=abs(0.5+0.5*j);
n=0:1:50;
for m=0:50
x(m+1)=a*c^m;
end
figure(2)
stem(n,x,'linewidth',2)
xlabel('n');
ylabel('x(n)');

View File

@ -0,0 +1,32 @@
import numpy as np
import matplotlib.pyplot as plt
def u(n):
return np.heaviside(n, 1)
def main():
# Part a
a = np.pi/4
n = np.arange(51)
x = 5*np.cos(a**2 * n)
plt.stem(n, x)
plt.xlabel("$n$")
plt.ylabel(r"$x[n] = 5\cos(a^2 n)$")
plt.show()
# Part b
A = 5
b = (1 + 1j)/2
x = A*np.abs(b)**n * u(n)
plt.stem(n, x)
plt.xlabel("$n$")
plt.ylabel("$x[n] = A|b|^n u(n)$")
plt.show()
if __name__ == "__main__":
main()

View File

@ -0,0 +1,10 @@
energy(1)=1;
for k=2:500
energy(k)=energy(k-1) + (1/(k*k));
end
a=(pi*pi/6)*ones(length(energy),1);
plot(energy,'linewidth',2)
hold
plot(a,'r','linewidth',2)
xlabel('Time index');
ylabel('Energy');

View File

@ -0,0 +1,26 @@
import numpy as np
import matplotlib.pyplot as plt
def u(n):
return np.heaviside(n, 1)
def main():
n = np.arange(101)
x = u(n-1)/n
# Avoid divide by zero
x[0] = 0
# Calculate the energy as a cumulative sum from n=0 to each sample
energy = np.cumsum(np.abs(x)**2)
plt.stem(n, energy)
plt.hlines(np.pi**2 / 6, n[0], n[-1], color='r')
plt.xlabel("Time index")
plt.ylabel("Energy")
plt.show()
if __name__ == "__main__":
main()

View File

@ -0,0 +1,30 @@
n=0:1:6;
x=[1 -5 4 -8 6 -3 -1];
figure(1)
stem(n,x,'linewidth',2)
xlabel('Time index');
ylabel('x(n)');
for m=0:6
u=mod(m+3,7);
y1(m+1)=x(u+1);
u=mod(m-4,7);
y2(m+1)=x(u+1);
u=mod(-m+2,7);
y3(m+1)=x(u+1);
end
figure(2)
stem(n,y1,'linewidth',2)
xlabel('Time index');
ylabel('x(n+3 mod 7)');
figure(3)
stem(n,y2,'linewidth',2)
xlabel('Time index');
ylabel('x(n-4 mod 7)');
figure(4)
stem(n,y3,'linewidth',2)
xlabel('Time index');
ylabel('x(-n+2 mod 7)');

View File

@ -0,0 +1,35 @@
import numpy as np
import matplotlib.pyplot as plt
def main():
n = np.arange(7) # n ranges from 0 to 7 (not including 7)
x = np.array([1, -5, 4, -8, 6, -3, -1])
x_1 = x[(n+3) % 7] # x[ <n+3>_7 ]
x_2 = x[(n-4) % 7] # x[ <n-4>_7 ]
x_3 = x[(-n+2) % 7] # x[ <-n+2>_7 ]
plt.subplot(411)
plt.stem(n,x)
plt.ylabel("$x[n]$")
plt.subplot(412)
plt.stem(n,x_1)
plt.ylabel(r"$x[\langle n+3 \rangle_7]$")
plt.subplot(413)
plt.stem(n, x_2)
plt.ylabel(r"$x[\langle n-4\rangle_7]$")
plt.subplot(414)
plt.stem(n, x_3)
plt.ylabel(r"$x[\langle -n+2\rangle_7]$")
plt.xlabel("$n$")
plt.show()
if __name__ == "__main__":
main()

View File

@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAwBCAWsvUNRP+Ar36WVT3eHR67OpHFewp67i1MKu9AKrd6HBL
wEbzcIK7yijJCNnqMmLhBtfV3olD1bEG2hEBdj8UujE23vk8zXCYf7SVuBZ4NX3+
gYVtGZlKSlmWpes245dslXtnOLvrxdtLh2ixZB7fDfNeO/I77VY2F0jzDdo3D6Wv
F8DDTCAPrfe2cIEACtFngwti8fXTCrkEo75uTdKbo2yT3FY3LWqS3cxoYAo4YOrF
VEWTyUlGK7PyB0NUjEwGQnLlqGGC4aEvKp6F65/RzycRyHSSkcPLsTRh5XY7d3uN
qbiRvpW5yR12QUh/dh7jYe0yvePGSFdDoS124wIDAQABAoIBAEzhDg/KERph80Yz
t1c0vI45yc61hFjRHIKff9+IjvIKcyMMeDXx8JXzrqmgI8BoQeeDTuHHWXNnbIDI
CJ8XOYeUfn59HqKoD1+Il3Je3aM/U0TONyavOtmJU4RpUfT+Lw1w2mUHbWz3Q8wC
GLyN+pvCA7T42pqSPsykuqgdajT7l42D4rUWzfI3mEeMMwvZwfVIaEtWR3TEJ+zW
24HFxjdNkqQWU/R2iY4phZOuLBiWI0HXEkMzONSHqUc+0BjJ2tCJLyzNqnffZFxz
9H2/NhgeQqNg2C83VNLfuCBnY5hqBwSUMAvXsGW6rLh/uWyfm9AwmNeivoCTcfhp
Bq8BydECgYEA4Y/Z5Y1AXKcQjZDxkjEGyfWHo/1GRlo2za5pxaEngMUZ6dXqHYtL
aWdk9iW5e5FLGCmPVEr38ixhPLMwHa+RT//a2xDG+zWBOZFkjagbiohYYaY904ED
Oy+zlY/MyCHp9rce5JjmWMcTT4Mc45UWiR8FG7JezTjnkKvhkgnLqAkCgYEA2ft2
um9PD4TVAn9ZFbJ+zznetIaiBXvUj7gwmbYKISMnq8jz3hy2FB3+8JVV3LVGKxPw
jbHrSuZG+zRW/CH25geCUU1HzHR6WD7pfMBu+mshoCMZl5cRlq0Nu5RbbnnnFqy3
Nw30Z6h7luN22+EHSIAuSuEk7FUyhWFU8U456osCgYEAhFscyQ4xjiyaEffTSK1s
BmYEyb181xtovRhzCHyf6Xe+1O+pCN0LyzXYkHdid5eyMONyL0wuYfSYuj2LJmA3
LHI9wf3+RLoIsfcWwei7AHcxJVufO9SgSMKc5k4TI/yChTq+7fSqdb2bHzUYZpK9
PojtPmtUJagWeVXibwdAccECgYAYw0VQlpZ/p9Je70KagWWAew1+qpC7WL7j+MOk
opZx/0FhdXmmsNJKZMHyaLSRVxJ6kFBSeHTHVHOZ0+9RwzX+GbpHLCVM56qCXds+
bcntrr/qJjKhEutPl6couQjN+xEydTp3CaHLKMupb3uwLNcb+FvJ69u68U7E8jKp
Gv7fUwKBgAkLZ4/aDSPMQKwZ0HEDb0829sakeOuUQW3aR7wa/aNY916Bkshz+xdO
9TW+PH9ouzIuyal0fB5syKETDjE8y5TCgrseKckMgp3IwZ7EGziiG7BGjJtl+Ryh
9Ic7oiooLluCWE3VEC9g70csl0pcLgOFbhdfytE4LXGlkwOMoQeG
-----END RSA PRIVATE KEY-----

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

View File

@ -0,0 +1,16 @@
---
title: Cloud Hardware Questions 1-10
author: Aidan Sharpe
date: Thursday, Feb 13th, 2025
---
1. b. Measured service
2. b. SaaS
3. b. Minimal cost
4. d. Orchestration
5. c. SLA
6. d. Resource pooling
7. b. SOC 2
8. d. API
9. b. Storage and c. Compute
10. b. While identifying the problem

View File

@ -23,6 +23,21 @@ This exercise transitions the breadboarded circuit from the last exercise to a p
The goal of the completed board is to have a common ground pin and individual power pins for each LEDs. This allows for independent control of the LEDs. The components are all to be permanently affixed to the protoboard with solder. In doing so, our prototype will be more durable than a simple breadboard layout. The goal of the completed board is to have a common ground pin and individual power pins for each LEDs. This allows for independent control of the LEDs. The components are all to be permanently affixed to the protoboard with solder. In doing so, our prototype will be more durable than a simple breadboard layout.
## Requirements
1. Traffic light LEDs
1. Traffic light shall have three (3) LEDs
2. The top LED (furthest from pin header) shall be red
3. The middle LED shall be yellow
4. The bottom LED (closest to pin header) shall be green
5. All LEDs shall have a 220$\Omega$ resistor connected in series to the power connection
2. Traffic light header
1. Header shall be 1 row, 6 positions, male (pins), 90-degree, through-hole mount, 100 mil pitch
2. Header shall be extend from the short side of the board
3. Pin 0 shall be a common ground pin
4. Pin 1 shall supply +5V to the red LED
5. Pin 2 shall supply +5V to the yellow LED
6. Pin 3 shall supply +5V to the green LED
## Procedure ## Procedure
First, we had to modify the protoboard and the pin header for them to mate properly. Since we are using stripboard as opposed to perfboard [@MorePCB], some of the pins would be shorted together through the pre-existing traces. We also had to remove two pins from the pin header, because the pins do not have a corresponding hole on the board. First, we had to modify the protoboard and the pin header for them to mate properly. Since we are using stripboard as opposed to perfboard [@MorePCB], some of the pins would be shorted together through the pre-existing traces. We also had to remove two pins from the pin header, because the pins do not have a corresponding hole on the board.

View File

@ -0,0 +1,19 @@
import numpy as np
import atmospheric_model as atmos
M = 400
D = 0.1
alpha = np.radians(40)
g = 9.81
a = 30*g
alt = 5000
v = 600
N = M*a
S_ref = np.pi * (D/2)**2
Q = atmos.dynamic_pressure(alt, v)
C_N = N/(Q*S_ref)
C_N_alpha = C_N/alpha
print(C_N_alpha)

View File

@ -0,0 +1,43 @@
import numpy as np
import matplotlib.pyplot as plt
def temperature(altitude):
if altitude > 25000:
return -131.21 + 0.00299*altitude
elif altitude > 11000:
return -56.46
else:
return 15.04 - 0.00649*altitude
def pressure(altitude):
T = temperature(altitude)
if altitude > 25000:
kpa = 2.488 * ((T+273.1)/216.6)**(-11.388)
elif altitude > 11000:
kpa = 22.65 * np.exp(1.73 - 0.000157*alititude)
else:
kpa = 101.29 * ((T+273.1)/288.08)**5.256
return 1000*kpa
def atmospheric_density(altitude):
p = pressure(altitude)
T = temperature(altitude)
return p / (286.9*(T+273.1))
def Mach(altitude, speed):
return speed/speed_of_sound(altitude)
def speed_of_sound(altitude):
gamma = 1.4
p = pressure(altitude)
rho = atmospheric_density(altitude)
return (gamma*p/rho)**0.5
def dynamic_pressure(altitude, speed):
rho = atmospheric_density(altitude)
return rho * speed**2 / 2

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -0,0 +1,20 @@
import numpy as np
import matplotlib.pyplot as plt
def CA(Mach):
return np.where(Mach > 1.0, 0.02 + 0.03/Mach,
np.where(Mach > 0.5, 0.02*(Mach-0.5) + 0.04, 0.04))
def main():
Mach = np.linspace(0,5,100)
plt.plot(Mach, CA(Mach))
plt.xlabel("Mach number")
plt.ylabel("CA")
plt.savefig("axial_drag.png")
plt.show()
if __name__ == "__main__":
main()

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

View File

@ -0,0 +1,125 @@
import atmospheric_model as atmos
import axial_drag
import numpy as np
import matplotlib.pyplot as plt
IGNORE_AIR_RESISTANCE = False
g = -9.81
v_initial = 600
S_ref = 0.1
mass = 10
T_s = 0.05
def main():
plt.figure(figsize=(16,9))
for elevation in np.arange(10,81,10):
theta = np.radians(elevation)
v_x = v_initial * np.cos(theta)
v_y = v_initial * np.sin(theta)
a_x = 0
a_y = g
t = 0
x = 0
y = 0
x_values = []
y_values = []
x_velocities = []
y_velocities = []
x_accelerations = []
y_accelerations = []
time = []
while y >= 0:
t += T_s
if not IGNORE_AIR_RESISTANCE:
v = (v_x*v_x + v_y*v_y)**0.5
Mach = atmos.Mach(y, v)
CA = axial_drag.CA(Mach)
Q = atmos.dynamic_pressure(y, v)
drag = CA*Q*S_ref
angle = np.arctan(v_y/v_x) + np.pi
drag_x = drag*np.cos(angle)
drag_y = drag*np.sin(angle)
a_x = drag_x/mass
a_y = drag_y/mass + g
x_accelerations.append(a_x)
y_accelerations.append(a_y)
x += v_x*T_s
x_values.append(x)
y += v_y*T_s
y_values.append(y)
v_x += a_x*T_s
x_velocities.append(v_x)
v_y += a_y*T_s
y_velocities.append(v_y)
time.append(t)
x_pos = np.array(x_values)/1000
y_pos = np.array(y_values)/1000
distance = (x_pos*x_pos + y_pos*y_pos)**0.5
v_x = np.array(x_velocities)
v_y = np.array(y_velocities)
speed = (v_x*v_x + v_y*v_y)**0.5
a_x = np.array(x_accelerations)/9.81
a_y = np.array(y_accelerations)/9.81
acceleration = (a_x*a_x + a_y*a_y)**0.5
plt.subplot(331)
plt.plot(time, x_pos)
plt.ylabel("Horizontal position [km]")
plt.subplot(332)
plt.plot(time, y_pos)
plt.ylabel("Vertical position [km]")
plt.subplot(333)
plt.plot(time, distance)
plt.ylabel("Total distance [km]")
plt.subplot(334)
plt.plot(time, v_x)
plt.ylabel("Horizontal velocity [m/s]")
plt.subplot(335)
plt.plot(time, v_y)
plt.ylabel("Vertical velocity [m/s]")
plt.subplot(336)
plt.plot(time, speed)
plt.ylabel("Speed [m/s]")
plt.subplot(337)
plt.plot(time, a_x)
plt.ylabel("Horizontal acceleration [g]")
plt.xlabel("Time [s]")
plt.subplot(338)
plt.plot(time, a_y)
plt.ylabel("Vertical acceleration [g]")
plt.xlabel("Time [s]")
plt.subplot(339)
plt.plot(time, acceleration)
plt.ylabel("Total acceleration [g]")
plt.xlabel("Time [s]")
plt.savefig("cannonball.png")
plt.show()
if __name__ == "__main__":
main()

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

View File

@ -0,0 +1,233 @@
---
title: Homework 1
author: Aidan Sharpe
date: February 10th, 2025
geometry: margin=1in
output:
pdf_document:
md_extension: native_numbering
---
# Develop an Atmospheric Model
```python
import numpy as np
import matplotlib.pyplot as plt
def temperature(altitude):
if altitude > 25000:
return -131.21 + 0.00299*altitude
elif altitude > 11000:
return -56.46
else:
return 15.04 - 0.00649*altitude
def pressure(altitude):
T = temperature(altitude)
if altitude > 25000:
kpa = 2.488 * ((T+273.1)/216.6)**(-11.388)
elif altitude > 11000:
kpa = 22.65 * np.exp(1.73 - 0.000157*alititude)
else:
kpa = 101.29 * ((T+273.1)/288.08)**5.256
return 1000*kpa
def atmospheric_density(altitude):
p = pressure(altitude)
T = temperature(altitude)
return p / (286.9*(T+273.1))
def Mach(altitude, speed):
return speed/speed_of_sound(altitude)
def speed_of_sound(altitude):
gamma = 1.4
p = pressure(altitude)
rho = atmospheric_density(altitude)
return (gamma*p/rho)**0.5
def dynamic_pressure(altitude, speed):
rho = atmospheric_density(altitude)
return rho * speed**2 / 2
```
# Determining $C_{N_\alpha}$
```python
import numpy as np
import atmospheric_model as atmos
M = 400
D = 0.1
alpha = np.radians(40)
g = 9.81
a = 30*g
alt = 5000
v = 600
N = M*a
S_ref = np.pi * (D/2)**2
Q = atmos.dynamic_pressure(alt, v)
C_N = N/(Q*S_ref)
C_N_alpha = C_N/alpha
print(C_N_alpha)
```
$C_{N_\alpha} = 161.69$
# Develop an Axial Drag Model
```python
import numpy as np
import matplotlib.pyplot as plt
def CA(Mach):
return np.where(Mach > 1.0, 0.02 + 0.03/Mach,
np.where(Mach > 0.5, 0.02*(Mach-0.5) + 0.04, 0.04))
def main():
Mach = np.linspace(0,5,100)
plt.savefig("axial_drag.png")
plt.plot(Mach, CA(Mach))
plt.show()
if __name__ == "__main__":
main()
```
![](axial_drag.png)
# Cannonball
```python
import atmospheric_model as atmos
import axial_drag
import numpy as np
import matplotlib.pyplot as plt
IGNORE_AIR_RESISTANCE = False
g = -9.81
v_initial = 600
S_ref = 0.1
mass = 10
T_s = 0.05
def main():
for elevation in np.arange(10,81,10):
theta = np.radians(elevation)
v_x = v_initial * np.cos(theta)
v_y = v_initial * np.sin(theta)
a_x = 0
a_y = g
t = 0
x = 0
y = 0
x_values = []
y_values = []
x_velocities = []
y_velocities = []
x_accelerations = []
y_accelerations = []
time = []
while y >= 0:
t += T_s
if not IGNORE_AIR_RESISTANCE:
v = (v_x*v_x + v_y*v_y)**0.5
Mach = atmos.Mach(y, v)
CA = axial_drag.CA(Mach)
Q = atmos.dynamic_pressure(y, v)
drag = CA*Q*S_ref
angle = np.arctan(v_y/v_x) + np.pi
drag_x = drag*np.cos(angle)
drag_y = drag*np.sin(angle)
a_x = drag_x/mass
a_y = drag_y/mass + g
x_accelerations.append(a_x)
y_accelerations.append(a_y)
x += v_x*T_s
x_values.append(x)
y += v_y*T_s
y_values.append(y)
v_x += a_x*T_s
x_velocities.append(v_x)
v_y += a_y*T_s
y_velocities.append(v_y)
time.append(t)
x_pos = np.array(x_values)/1000
y_pos = np.array(y_values)/1000
distance = (x_pos*x_pos + y_pos*y_pos)**0.5
v_x = np.array(x_velocities)
v_y = np.array(y_velocities)
speed = (v_x*v_x + v_y*v_y)**0.5
a_x = np.array(x_accelerations)/9.81
a_y = np.array(y_accelerations)/9.81
acceleration = (a_x*a_x + a_y*a_y)**0.5
plt.subplot(331)
plt.plot(time, x_pos)
plt.ylabel("Horizontal position [km]")
plt.subplot(332)
plt.plot(time, y_pos)
plt.ylabel("Vertical position [km]")
plt.subplot(333)
plt.plot(time, distance)
plt.ylabel("Total distance [km]")
plt.subplot(334)
plt.plot(time, v_x)
plt.ylabel("Horizontal velocity [m/s]")
plt.subplot(335)
plt.plot(time, v_y)
plt.ylabel("Vertical velocity [m/s]")
plt.subplot(336)
plt.plot(time, speed)
plt.ylabel("Speed [m/s]")
plt.subplot(337)
plt.plot(time, a_x)
plt.ylabel("Horizontal acceleration [g]")
plt.xlabel("Time [s]")
plt.subplot(338)
plt.plot(time, a_y)
plt.ylabel("Vertical acceleration [g]")
plt.xlabel("Time [s]")
plt.subplot(339)
plt.plot(time, acceleration)
plt.ylabel("Total acceleration [g]")
plt.xlabel("Time [s]")
plt.savefig("cannonball.png")
plt.show()
if __name__ == "__main__":
main()
```
![](cannonball.png)