首页 > 其他分享 >习题2.5(1)

习题2.5(1)

时间:2024-10-15 16:43:03浏览次数:1  
标签:plt set linspace np ax 习题 100 2.5

1.代码实现

点击查看代码
import numpy as np
import matplotlib.pyplot as plt

#横纵坐标
x=np.linspace(-5,5,100)
y=np.linspace(-5,5,100)

#网格生成
X,Y=np.meshgrid(x,y)

#写法一
plt.rc('font',family='SimHei')
plt.rc('axes',unicode_minus=False)
#写法二
#plt.rcParams['font.sans-serif'] = ['SimHei']  # 设置中文字体为SimHei
#plt.rcParams['axes.unicode_minus'] = False  # 正确显示负号


Z_positive=()

a = 4
b = 10
c = 8

# 定义x和y的范围
x = np.linspace(-5, 5, 100)
y = np.linspace(-5, 5, 100)

# 生成网格
X, Y = np.meshgrid(x, y)

# 计算Z值
Z_positive = (a**2 * X**2 + b**2 * Y**2 + c**2) / (2 * c**2)

# 创建3D图形
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# 绘制曲面
ax.plot_surface(X, Y, Z_positive, cmap='viridis')

ax.set_xlabel('X轴')
ax.set_ylabel('Y轴')
ax.set_zlabel('Z轴')

plt.show()


2.运行结果

标签:plt,set,linspace,np,ax,习题,100,2.5
From: https://www.cnblogs.com/qishanhsa/p/18467869

相关文章

  • 计算机网络教程 | 第一章 计算机网络概述 课堂习题
    一.单选题TCP/IP是四层的体系结构:应用层、运输层、网际层和()。A.网络接口层B.物理层C.网络层D.数据链路层正确答案:A 20世纪60年代,美国国防部高级研究计划局提出的网络研究课题的名称为()。A.ARPAnetB.LANC.WAND.TCP/IP正确答案:A 运输层的......
  • 计算机网络教程 | 第二章 物理层 课堂习题
    单选题一个数据通信系统不包括()。A.源系统B.传输系统C.目的系统D.复用器正确答案:D答案解析:(p34)一个数据通信系统可划分为三大部分,即源系统(或发送端、发送方)、传输系统(或传输网络)和目的系统(或接收端、接收方)。 以下关于物理层的描述中,错误的是()。A.物理层处于......
  • 数学建模习题6.2
    edges=[("Pe","T",13),("Pe","N",68),("Pe","M",78),("Pe","L",51),("Pe","Pa",51),("T","N",68),("T","M......
  • 数学建模习题6.3
    importheapqdefprim(graph,start):num_nodes=len(graph)visited=[False]*num_nodesmin_heap=[(0,start,-1)]mst_cost=0mst_edges=[]whilemin_heap:weight,u,parent=heapq.heappop(min_heap)ifvisited[u]:continue......
  • 数学建模习题5.4
    importnumpyasnpfromscipy.optimizeimportminimizedefobjective(x):return-np.sum(np.sqrt(x)*np.arange(1,101))defconstraint1(x):returnx[1]-10defconstraint2(x):return20-(x[1]+2*x[2])defconstraint3(x):return30-(x[1]+2x[2]+3x......
  • 数学建模习题5.5
    importnumpyasnpfromscipy.optimizeimportminimizedefobjective(x):return2x[0]+3x[0]2+3*x[1]+x[1]2+x[2]defconstraint1(x):return10-(x[0]+2x[0]**2+x[1]+2x[1]**2+x[2])defconstraint2(x):return50-(x[0]+x[0]2+x[1]+x[1]2......
  • 数学建模习题5.7
    total_demand=sum(demands)dp=np.full((4,total_demand+1),float('inf'))dp[0][0]=0prev_production=np.full((4,total_demand+1),-1)foriinrange(1,4):prev_demand=sum(demands[:i-1])forjinrange(total_demand+1):ifj<pr......
  • 数学建模习题4.4
    `MAX_B=24MAX_DEBUG=5products=[{"name":"Ⅰ","A_hours":1,"B_hours":6,"debug_hours":1,"profit":2},#假设产品Ⅰ至少使用1小时设备A{"name":"Ⅱ","A_hours":5,"......
  • 数学建模习题3.3
    importnumpyasnpfromscipy.sparse.linalgimporteigsimportpylabaspltw=np.array([[0,1,0,1,1,1],[0,0,0,1,1,1],[1,1,0,1,0,0],[0,0,0,0,1,1],[0,0,1,0,0,1],[0,0,1,0,0,0]])r=np.sum(w,axis=1,keepdims=True)n=w.sha......
  • 数学建模习题2.4
    importnumpyasnpimportmatplotlib.pyplotasplt定义x的范围x=np.linspace(-10,10,400)创建一个2行3列的子图布局fig,axs=plt.subplots(2,3,figsize=(12,8))遍历每个子图fork,axinenumerate(axs.flat,start=1):y=k*x**2+2*kax.plot(x,y,label......