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. vue 3.0新特性

    参考:  https://www.cnblogs.com/Highdoudou/p/9993870.html https://www.cnblogs.com/ljx20180807/p/9987822 ...

  2. hdu3397 Sequence operation 线段树

    hdu3397 Sequence operation #include <bits/stdc++.h> using namespace std; ; struct node { /// l ...

  3. PAT-1135 Is It A Red-Black Tree(二叉查找树的创建和遍历)

    There is a kind of balanced binary search tree named red-black tree in the data structure. It has th ...

  4. LibreOJ #515 贪心只能过样例

    题目链接:https://loj.ac/problem/515 知识点: DP.bitset类 解题思路: DP部分不难想到:从 a 到 b 遍历,然后在已有的状态上加上遍历得到的数字的平方,难点在于 ...

  5. 【Mac】pip自定义源【永久有效】

    鉴于国内网络环境,pip安装比较慢已成为不争的事实,通过以下几步轻松解决 1.创建文件夹   mkdir -/.pip 2.创建配置文件  vim -/.pip/pip.conf mkdir ~/.p ...

  6. Angular SPA基于Ocelot API网关与IdentityServer4的身份认证与授权(四)

    在上一讲中,我们已经完成了一个完整的案例,在这个案例中,我们可以通过Angular单页面应用(SPA)进行登录,然后通过后端的Ocelot API网关整合IdentityServer4完成身份认证.在 ...

  7. Java——反射三种方式的效率对比

    转载自:https://blog.csdn.net/aitcax/article/details/52694423 1 使用field(效率最高)             long start = S ...

  8. Spring MyBatis配置文件

    Config文件夹 log4j.properties配置文件 # # Global logging configuration log4j.rootLogger=DEBUG, stdout # Con ...

  9. 第二章-数据绑定和第一个AnglarJS Web应用

    Angularjs中的数据绑定 AngularJS创建实时模板来代替视图,而不是将数据合并进模板之后更新DOM.任何一个独立视图组件中的值都是动态替换的.这个功能可以说是AngularJS中最最重要的 ...

  10. html5学习之路_003

    html布局 使用<div>元素布局 使用<table>元素布局 <div>元素布局 <!DOCTYPE html> <html> < ...