Reputation: 13
I want a sinus with linear increasing frequency in the range [f_start : f_stop]
over time.
However, when creating the appropriate signal in Python the last period has approximately twice the frequency expected, 2*f_stop
.
Why?
Here some minimal Python code which illustrates the problem:
import numpy
import matplotlib.pyplot as plt
Delta_t = 1 # Unit: Seconds
samples = 1000
total_time = samples*Delta_t
t = numpy.linspace(0,total_time,num=samples)
f_start = 1.0/total_time # slow frequency (Period T = 1/f_start = 1000 samples)
f_stop = 100.0/total_time # high frequency (Period T = 1/f_stop = 10 samples)
f_sweep = numpy.linspace(f_start,f_stop,num=samples) # Sweep from slow to high frequency
# Create Sinusoids
sinus_f_start = numpy.sin(2*numpy.pi*f_start*t)
sinus_f_stop = numpy.sin(2*numpy.pi*f_stop*t)
sinus_f_sweep = numpy.sin(2*numpy.pi*f_sweep*t)
# Plot all sinusoids
fig = plt.figure()
fig.add_subplot(311)
plt.plot(t,sinus_f_start)# Perfect! 1000 Samples per period.
fig.add_subplot(312)
plt.plot(t,sinus_f_stop) # Perfect! 10 Samples per period.
fig.add_subplot(313)
plt.plot(t,sinus_f_sweep)# Fail! Last period has 5 samples.
plt.show()
Upvotes: 1
Views: 3384
Reputation: 25053
sin(w*t) => the angular velocity is d(w*t)/dt = w
sin(w*t*t) => the angular velocity is d(w*t*t)/dt = 2*w*t
hence the perceived doubling in the maximum frequency
Upvotes: 3