파이썬/동국대_정보통신수학(김동환 교수님♥)
Lecture4 _ 삼각함수
낭데뷰
2019. 3. 26. 11:56
#1. sin(주기1, 주파수 1), cos(주기2, 주파수 1/2)그래프 그리기
import numpy as np
from math import pi
import matplotlib.pyplot as plt
xvals = np.linspace(-pi, pi, num=1000) #-pi와 pi사이에 1000개의 점 찍기
ysin = np.sin(2*pi*1*xvals)
ycos = np.cos(2*pi*0.5*xvals)
plt.plot(xvals, ysin, '*r')
plt.plot(xvals, ycos, 'sg')
plt.title('sin:red, cos:green')
plt.xlabel('Input')
plt.ylabel('Function values')
plt.axis([-pi, pi, -1, 1])
plt.grid()
plt.show()
[Result]