Skip to content
Snippets Groups Projects
Commit 3548aa15 authored by Erik Strand's avatar Erik Strand
Browse files

Generate two plots

parent 7a1b878c
No related branches found
No related tags found
No related merge requests found
import numpy as np
import matplotlib.pyplot as plt
def sample_two_sins(f1, f2, sample_times):
sample_rads = 2 * np.pi * sample_times
return np.sin(f1 * sample_rads) + np.sin(f2 * sample_rads)
if __name__ == "__main__":
f1 = 697 # Hz
f2 = 1209 # Hz
sample_period = 0.01
n_samples = 1000
sample_times = (sample_period / n_samples) * np.arange(n_samples)
sample_values = sample_two_sins(f1, f2, sample_times)
fig, ax = plt.subplots()
ax.plot(sample_times, sample_values)
sample_period = 0.02
n_samples = 1000
sample_times = (sample_period / n_samples) * np.arange(n_samples)
sample_values = sample_two_sins(f1, f2, sample_times)
fig2, ax2 = plt.subplots()
ax2.plot(sample_times, sample_values)
plt.figure(fig.number)
plt.savefig("test.png")
plt.figure(fig2.number)
plt.savefig("test2.png")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment