공부중에 매트랩의 sinc 함수를 찾지 못해서
매트랩은 아니지만 python 전용으로 sinc 함수를 만들어 봤다. 주의할 부분은 sin 함수 안의 매개변수 값의 단위가 degree 인지 radian 인지 명확히 인지 해야 한다. python math의 sin은 radian이다.
즉 3.141592 radian = 180 degree이다.

Code
import math import matplotlib.pyplot as plt import numpy as np def sinc(x): if x == 0: return 1 else: return (math.sin(math.pi * x) / (math.pi * x)) x = np.linspace(-5,5,1000) y = [] for valueX in x: y.append(sinc(valueX)) plt.plot(x,y) plt.show()결과

'Program > Python' 카테고리의 다른 글
가장 많이 나오는 문자열 찾기 (collections의 Counter 함수) (0) | 2022.08.02 |
---|---|
itertools의 순열(permutation), 조합(combination) (0) | 2022.08.02 |
K번째 큰 수 (0) | 2021.05.06 |
람다 표현식 (0) | 2021.04.24 |
2차원 리스트 다루기 (0) | 2021.04.13 |