Issue
I need to do a plot of this function c(t) = (e^(-10t^2))*cos(2pi50t) * (u(t + 3) - u(t - 3)). I don't understand how I can do it. I've already defined the variables of the trigonometric function but I don't know what I have to do with the other function. This is what I have:
import matplotlib.pyplot as plt
import numpy as np
t= np.arange(0,0.5,0.001)
A= np.exp(-10*(t**2))
f=50
c1 = A * np.cos(2 * np.pi * f * t)
c2 = (u(t+3)-u(t-3))
Solution
Assuming u
is the identity function (returns the input as is), this is the code you need to plot the function. I have used your variable definition and used t
as an input to the function for flexibility:
def u(x):
return x
def function_c(t):
A= np.exp(-10*(t**2))
f=50
c1 = np.cos(2 * np.pi * f * t)
c2 = (u(t+3) - u(t-3))
return A * c1 * c2
t= np.arange(0,0.5,0.001)
plt.plot(t, function_c(t))
Of course, if you ever learn the definition of u
, you can update the definition of u(x)
and recalculate your plot.
Answered By - Carlos Melus
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.