首页 > 其他分享 >7.4(学号:3025)

7.4(学号:3025)

时间:2024-11-18 17:00:51浏览次数:1  
标签:xy0 3025 random fig 7.4 np y0 x0

import numpy as np
from scipy.interpolate import interp1d, interp2d, UnivariateSpline, griddata
import matplotlib.pyplot as plt
np.random.seed(114514)

x0 = np.random.uniform(-3, 3, 50)
y0 = np.random.uniform(-4, 4, 50)
f = lambda x, y: (x2 - 2x)np.exp(-x2 - y**2 - x*y)
z0 = f(x0, y0)

xy0 = np.vstack([x0, y0]).T
x = np.linspace(x0.min(), x0.max(), 300)
y = np.linspace(y0.min(), y0.max(), 300)
X, Y = np.meshgrid(x, y)
z = griddata(xy0, z0, (X,Y), 'cubic')
zl = griddata(xy0, z0, (X,Y), 'linear')
z[np.isnan(z)] = zl[np.isnan(z)]

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, z, cmap='hot')
fig.show()

标签:xy0,3025,random,fig,7.4,np,y0,x0
From: https://www.cnblogs.com/tjs200461/p/18553076

相关文章

  • 7.3(学号:3025)
    importnumpyasnpfromscipy.interpolateimportinterp1d,interp2d,UnivariateSpline,griddataimportmatplotlib.pyplotaspltt0=np.linspace(700,780,5)v0=np.array([0.0977,0.1218,0.1406,0.1551,0.1664])f1=interp1d(t0,v0)f2=interp1d(t0,v......
  • 8.5(学号:3025)
    importnumpyasnpimportpandasaspdimportsympyasspsp.init_printing(use_latex=True)fromscipy.integrateimportodeintimportmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']pl......
  • 8.4 (学号:3025)
    importnumpyasnpimportpandasaspdimportsympyasspsp.init_printing(use_latex=True)fromscipy.integrateimportodeintimportmatplotlib.pyplotaspltplt.rcParams['font.sans-serif']=['TimesNewRoman+SimSun+WFMSansSC']pl......
  • 7.1 7.3 7.4 7.7 7.10
    7.1点击查看代码importnumpyasnpimportscipy.interpolateasspiimportscipy.integrateasspi_integratedefg(x):return((3*x**2+4*x+6)*np.sin(x))/(x**2+8*x+6)x_values=np.linspace(0,10,1000)y_values=g(x_values)spline=spi.C......
  • 习题7.4
    1.代码实现点击查看代码importnumpyasnpfromscipy.interpolateimportgriddataimportmatplotlib.pyplotasplt#定义函数deff(x,y):return(x**2-2*x)*np.exp(-x**2-y**2-x*y)#生成随机点np.random.seed(0)x_random=np.random.uni......
  • 数学建模习题7.4
    `importnumpyasnpimportmatplotlib.pyplotaspltfromscipy.interpolateimportgriddatadeff(x,y):x2=x2return(x2-2*x)*np.exp(-x2-y2-x*y)x_min,x_max=-3,3y_min,y_max=-4,4num_points=1000x_random=np.random.uniform(x_min,x_ma......
  • 极狐GitLab 发布安全补丁版本17.5.2, 17.4.4, 17.3.7
    本分分享极狐GitLab补丁版本17.5.2,17.4.4,17.3.7的详细内容。这几个版本包含重要的缺陷和安全修复代码,我们强烈建议所有私有化部署用户应该立即升级到上述的某一个版本。对于极狐GitLabSaaS,技术团队已经进行了升级,无需用户采取任何措施。极狐GitLab正式推出面向GitLab......
  • Linux二进制安装 MySQL 5.7.44
    1.下载MySQL5.7.44的二进制文件首先,访问MySQL官网下载页面,选择适合你操作系统架构(如x86_64)的二进制安装包。访问官网:MySQLDownloads在页面中选择适合你系统的版本(比如Linux的 tar 包)。下载Mysql  https://download.csdn.net/download/m0_58223765/89975252例......
  • 7.4
    importnumpyasnpimportmatplotlib.pyplotaspltfromscipy.interpolateimportgriddatadeff(x,y):return(x2-2*x)*np.exp(-x2-y**2-x*y)x_min,x_max=-3,3y_min,y_max=-4,4num_points=1000x_random=np.random.uniform(x_min,x_max,num_......
  • 习题7.4
    importnumpyasnpfromscipy.interpolateimportinterp1d,interp2d,UnivariateSpline,griddataimportmatplotlib.pyplotaspltnp.random.seed(114514)x0=np.random.uniform(-3,3,50)y0=np.random.uniform(-4,4,50)f=lambdax,y:(x**2-2*x)*np.ex......