Question

How can I draw plot of formula: x(t)=cos(2π·10t)+cos(2π·25t)+ cos(2π· 50t) +cos(2π·100t)

Was it helpful?

Solution

This is rather simple: Declare your t array, compute x(t) array, plot it with matplotlib.

import numpy as np
import matplotlib.pyplot as plt

# Declare t array
t = np.arange(0.0,2.0,0.01) # change your end point and step as you want it

# Compute x(t) with numpy
x = np.cos(2*np.pi*10*t) + np.cos(2*np.pi*25*t) + np.cos(2*np.pi*50*t) + np.cos(2*np.pi*100*t)

# Plot t with x
plt.plot(t,x)
plt.show()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top