meshgrid计算函数sqrt(x^2+y^2)

来源:互联网 发布:淘宝网模特兼职 编辑:程序博客网 时间:2024/06/16 18:37
import numpy as nppoints=np.arange(-5,5,0.01)#1000个间隔相同的点xs,ys=np.meshgrid(points,points)#生成两个二维矩阵print(ys)import matplotlib.pyplot as pltz=np.sqrt(xs ** 2 + ys ** 2)#计算函数print(z)plt.imshow(z, cmap=plt.cm.gray);plt.colorbar()plt.title("Image plot of $\sqrt{x^2 + y^2}$ for a grid of values")

这里写图片描述

阅读全文
0 0
原创粉丝点击