everyone!
I'm learning about signals now, but I'm having a tough time trying to plot more than one period using pyplot. I don't know if the problem is with the mathematical part or with the code itself. I think this is a silly question, but any help would be great!
import numpy as np
import matplotlib.pyplot as plt
def function(t):
return t**2
# Fundamental Period and Frequency:
T = 2*np.pi
w = 2*np.pi/T
# Defining the limits and the x values(in our case, time):
inferior_limit, superior_limit = -np.pi, np.pi
time_values = np.linspace(inferior_limit, superior_limit, 1000)
# Desired function plot:
plt.style.use('bmh')
plt.plot(time_values, function(time_values), color='k')
plt.show()
The main problem here is that t²
is not a periodic function. The graph of the function you want is (((t + π) % (2π)) - π)²
(graph).
You can implement that in the function
function as:
def function(t):
return (((t + np.pi) % (2*np.pi)) - np.pi)**2