import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt # function that returns dy/dt
def model(y,t):
# u steps from 0 to 2 at t=10
if t<10.0:
u = 0
else:
u = 2
dydt = (-y + u)/5.0
return dydt # initial condition
y0 = 1 # time points
t = np.linspace(0,40,1000) # solve ODE
y = odeint(model,y0,t) # plot results
plt.plot(t,y,'r-',label='Output (y(t))')
plt.plot([0,10,10,40],[0,0,2,2],'b-',label='Input (u(t))')
plt.ylabel('values')
plt.xlabel('time')
plt.legend(loc='best')
plt.show()

ODEINT 求解常微分方程(2)的更多相关文章

  1. ODEINT 求解常微分方程(4)

    import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt # function tha ...

  2. ODEINT 求解常微分方程(3)

    import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt # function tha ...

  3. ODEINT 求解常微分方程(1)

    An example of using ODEINT is with the following differential equation with parameter k=0.3, the ini ...

  4. MATLAB求解常微分方程:ode45函数与dsolve函数

    ode45函数无法求出解析解,dsolve可以求出解析解(若有),但是速度较慢. 1.      ode45函数 ①求一阶常微分方程的初值问题 [t,y] = ode45(@(t,y)y-2*t/y, ...

  5. 欧拉法求解常微分方程(c++)

    #include<iostream> #include<iomanip> using namespace std; int main() { double x, y, h;   ...

  6. 改进欧拉公式求解常微分方程(c++)

    #include<iostream> #include<iomanip> using namespace std; int main() { double x,y,h,temp ...

  7. 梯形法求解常微分方程(c++)

    #include<iostream> #include<iomanip> using namespace std; int main() { double x,y,yn,h,t ...

  8. 后退欧拉法求解常微分方程(c++)

    #include<iostream> #include<iomanip> using namespace std; int main() { double x,y,yn,h,t ...

  9. 欧拉法求解常微分方程(c++)【转载】

    摘自<c++和面向对象数值计算>,代码简洁明快,采用类进行封装实现代码,增强代码的重用性,通过继承可实现代码的重用,采用函数指针,通用性增强,在函数改变时只需要单独改变函数部分的代码,无需 ...

随机推荐

  1. Java Thread中,run方法和start方法的区别

     两种方法的区别: 1.start方法 用 start方法来启动线程,是真正实现了多线程, 通过调用Thread类的start()方法来启动一个线程,这时此线程处于就绪(可运行)状态,并没有运行,一旦 ...

  2. 数据结构----二叉树Tree和排序二叉树

    二叉树 节点定义 class Node(object): def __init__(self, item): self.item = item self.left = None self.right ...

  3. 8.3 Go channel

    8.3 Go channel 在Go语言中,关键字go的引入使得Go语言并发编程更加简单而优雅,但是并发编程的复杂性,以及时刻关注并发编程容易出现的问题需要时刻警惕. 并发编程的难度在于协调,然而协调 ...

  4. 3.4 Go字符型

    1. Go字符型 Golang 中没有专门的字符类型,如果要存储单个字符(字母),一般使用 byte 来保存. 普通字符串就是一串固定长度的字符连接起来的字符序列. Go 的字符串是由单个字节连接起来 ...

  5. Jenkins-插件开发(简单demo)

    推荐:官网创建插件案例:https://jenkins.io/doc/developer/tutorial/run/ 官方的这篇文章讲的很详细了,我就补充补充其中遇到的一些问题. 前置条件:maven ...

  6. STM32F103出现CPU could not be halted问题的解决方案

    问题描述: **JLink Warning: CPU could not be halted ***JLink Error: Can not read register 15 (R15) while ...

  7. SVN:TortoiseSVN SendRpt.exe not found 完美解决

    今天来上班的时候,发现公司用的svn版本和我自己的不一致,其实可以使用但是还是神经质的更新了一下.结果每次右键都会出一个异常.下图所示. 期初以为是哪里配置错误,或者版本冲突,经过网上查找办法,完美解 ...

  8. 模板:list列表显示

    作为视图,担当的角色就是显示数据.所以关键就是,借助JSTL的c:forEach标签遍历从CategoryServlet的list()的request.setAttribute("thecs ...

  9. swiper插件在移动端,多个swiper左右滑动时有空白的问题

    之前在项目上用到了多个swiper.但是结构结构代码css.以及js  几乎一样的除了第一个swiper左右滑动有回弹.其他都没有回弹.于是尝试了各种方法都不行. 百思不得其解 ,最后在官网终于找到了 ...

  10. get_client_ip()

    get_client_ip()获取ip地址,在开启IPv6协议的主机上会全部返回0.0.0.0原因是他会把ipv6地址认为是非法地址而转换成0.0.0.0,而ipv4地址在ipv6主机上用get_cl ...