I have this signal :
from math import*
Fs=8000
f=500
sample=16
a=[0]*sample
for n in range(sample):
a[n]=sin(2*pi*f*n/Fs)
How can I plot a
x-axis
with np.arange(0, 1, 0.001)
gives an array from 0 to 1 in 0.001 increments.
x = np.arange(0, 1, 0.001)
returns an array of 1000 points from 0 to 1, and y = np.sin(2*np.pi*x)
you will get the sin wave from 0 to 1 sampled 1000 timesI hope this will help:
import matplotlib.pyplot as plt
import numpy as np
Fs = 8000
f = 5
sample = 8000
x = np.arange(sample)
y = np.sin(2 * np.pi * f * x / Fs)
plt.plot(x, y)
plt.xlabel('sample(n)')
plt.ylabel('voltage(V)')
plt.show()
P.S.: For comfortable work you can use The Jupyter Notebook.