Python中文
首页
教程
问答
标签
搜索
登录
注册
在python中使用matplotlib打印?
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我一直试图用四阶<a href="https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods" rel="nofollow">Runge-Kutta method</a>来模拟一阶微分方程,但在绘制它时遇到了问题。你知道吗</p> <pre><code>#simulation of ode using 4th order rk method dy/dx=-2y+1.3e^-x,y(0)=5,h=0.01 from sympy import* import math import numpy as np import matplotlib.pyplot as plt h=0.01; ti=0; x=0; n=0; y=5; def f(x,y): return 1.3*math.exp(-x)-2*y while x < 10: k1=f(x,5); k2=f(x+h/2,y+(h/2)* k1); k3=f(x+h/2,y+(h/2)* k2); k4=f(x+h,y+h*k3); y=y+h/6*(k1+2*(k2+k3)+k4); x=x+h; plt.plot(x,y); </code></pre> <p>我知道问题是因为每次循环运行时都会更新x,y值,但是有人能解释一下如何绘制(x,y)的所有值吗?你知道吗</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>另一个错误结果的来源是RK4循环中的第一行。而不是</p> <pre><code> k1=f(x,5); </code></pre> <p>使用</p> <pre><code> k1=f(x,y); </code></pre> <p>因为<code>y</code>的值不会在初始值保持不变。你知道吗</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何为此数据帧创建散点图?
1 回答
如何为此编写Django模板
8 回答
如何为此表达式编写正则表达式?
9 回答
如何为步进电机选择合适的值?
8 回答
如何为每15分钟间隔的日期时间行(在新列中)添加标签?
1 回答
如何为每一列创建汇总表?
3 回答
如何为每一组groupbyPandas做滚动“得到假人”
5 回答
如何为每一行分别运行函数(python)?
1 回答
如何为每一行生成一个随机数?
6 回答
如何为每一轮将pytorch模型输出存储到numpy
3 回答
如何为每个.py-fi文件创建单独的zip文件
7 回答
如何为每个<li class=”“><a>找到最近的上述同级<li>?
7 回答
如何为每个CSV列生成特定的文件?
2 回答
如何为每个csv文件使用read_csv,即使它是空的?PythonPandas
9 回答
如何为每个CSV文件创建单独的Pandas数据帧并给它们起有意义的名称?
2 回答
如何为每个datetime和每个id创建一行?
6 回答
如何为每个Django型号选择赋予不同的颜色
10 回答
如何为每个Django模型实例安排一个周期性的芹菜任务?
10 回答
如何为每个Django视图设置一个装饰器?
1 回答
如何为每个for循环迭代分配变量
10 回答