{
int nSmallCx = ::GetSystemMetrics(SM_CXSMICON)
int nSmallCy = ::GetSystemMetrics(SM_CYSMICON)
m_ImgList.Create(nSmallCx, nSmallCy, ILC_MASK|ILC_COLOR32, 0, 1)
m_treeview.SetImageList(m_ImgList)
}
//往Treeview添加节点,图标从指定exe或dll文件获取,如果获取失败,使用指定序号图标
一、函数说明在使用python作图时,应用最广的就是matplotlib包,但我们平时使用matplotlib时主要是画一些简单的图表,很少有涉及分段函数。本次针对数值实验中两个较为复杂的函数,使用其构建分段函数图像。
二、图像代码
2.11、函数公式:
y=4sin(4πt)-sgn(t-0.3)-sgn(0.72-t)
2.12、代码如下:
import numpy as np
import matplotlib.pyplot as plt
def sgn(x):
if x>0:
return 1
elif x<0:
return -1
else:
return 0
t=np.arange(0,1,0.01)
y=[]
for i in t:
y_1=4*np.sin(4*np.pi*i)-sgn(i-0.3)-sgn(0.72-i)
y.append(y_1)
plt.plot(t,y)
plt.xlabel("t")
plt.ylabel("y")
plt.title("Heavsine")
plt.show()
2.13、运行结果如下:
81036331d721706ae12808beb99b9574.png
2.21、函数公式:
479029.html
2.22、代码如下:
import numpy as np
import matplotlib.pyplot as plt
def g(x):
if x>0:
return x
else:
return 0
t=np.arange(0,1,0.01)
y=[]
for i in t:
y_1=g(i*(1-i))*np.sin((2*np.pi*1.05)/(i+0.05))
y.append(y_1)
plt.plot(t,y)
plt.xlabel("t")
plt.ylabel("y")
plt.title("TimeSine")
plt.show()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)