1
방금 비슷한 코드를 올렸지 만 지금은 다른 문제가 있습니다. ive bound y가 0 또는 1이고 주어진 x가 큰 값 집합을 취하기를 원한다면 x와 y를 같은 차원으로 가져 오는 방법은 무엇입니까? 목표는 헤비 사이드 함수를 플롯하는 경우, 당신은 사용할 수 있습니다x와 y를 같은 크기로 맞추기
#Part A - Plot function against values of variable x
import numpy as np
import matplotlib.pyplot as plt
import scipy.integrate as quad
import math
#Make heaviside "theta" function
def heaviside (x):
if np.any(x >= 0):
return 1
else:
return 0
#Plot
x = np.linspace(-5,5,11)
y = heaviside(x)*[1-heaviside(x-1)]
plt.plot(x, y)
plt.show()