Matlab微分方程符号解和数值解 您所在的位置:网站首页 xlnx=-2的解 Matlab微分方程符号解和数值解

Matlab微分方程符号解和数值解

2024-07-17 14:31| 来源: 网络整理| 查看: 265

符号解用dsolve函数 例 求微分方程 y′′+4y′+4y=e−2x

dsolve('D2y+4*Dy+4*y=exp(-2*x)')

结果

ans = 1/(4*exp(2*x)) + C5/exp(2*t) + (C6*t)/exp(2*t)

例 求解微分方程 x2y′+xy=y2,y(1)=1 的特解

dsolve('x^2*Dy+x*y=y^2','y(1)=1')

结果

ans = -(x*(tan(-(x*((- 1 + 2*x*atan((2*i)/x - i)*i)/x^2 + t/x^2)*i)/2) + i)*i)/2

数值解用龙格库塔方法 函数 [X,Y]=ode23(′f′,[x0,xn],y0) [X,Y]=ode45(′f′,[x0,xn],y0) f是函数, y0 是初值, [x0,xn] 是区间 ode23是二阶三阶龙格库塔方法,ode45是四阶五阶龙格库塔方法 例 求微分方程

⎧⎩⎨dydx=−3y+2xy(0)=1 在[1,3]区间内的数值解。 f.m

function f=f(x,y) f=-3.*y+2.*x; end

输入命令

[X,Y]=ode45('f',[1 3],1); X',Y'

结果

ans = Columns 1 through 8 1.0000 1.0500 1.1000 1.1500 1.2000 1.2500 1.3000 1.3500 Columns 9 through 16 1.4000 1.4500 1.5000 1.5500 1.6000 1.6500 1.7000 1.7500 Columns 17 through 24 1.8000 1.8500 1.9000 1.9500 2.0000 2.0500 2.1000 2.1500 Columns 25 through 32 2.2000 2.2500 2.3000 2.3500 2.4000 2.4500 2.5000 2.5500 Columns 33 through 40 2.6000 2.6500 2.7000 2.7500 2.8000 2.8500 2.9000 2.9500 Column 41 3.0000 ans = Columns 1 through 8 1.0000 0.9559 0.9226 0.8987 0.8827 0.8735 0.8703 0.8722 Columns 9 through 16 0.8785 0.8885 0.9017 0.9178 0.9363 0.9568 0.9791 1.0030 Columns 17 through 24 1.0282 1.0545 1.0818 1.1099 1.1388 1.1683 1.1983 1.2287 Columns 25 through 32 1.2596 1.2908 1.3224 1.3541 1.3861 1.4183 1.4506 1.4831 Columns 33 through 40 1.5157 1.5484 1.5812 1.6140 1.6470 1.6799 1.7130 1.7460 Column 41 1.7792

例 求微分方程

⎧⎩⎨5dydx+y=1y(0)=2 的数值解。 f.m

function f=f(x,y) f=-y./5+1/5; end

输入命令

[X,Y]=ode45('f',[1 3],2); X',Y'

结果

ans = Columns 1 through 8 1.0000 1.0500 1.1000 1.1500 1.2000 1.2500 1.3000 1.3500 Columns 9 through 16 1.4000 1.4500 1.5000 1.5500 1.6000 1.6500 1.7000 1.7500 Columns 17 through 24 1.8000 1.8500 1.9000 1.9500 2.0000 2.0500 2.1000 2.1500 Columns 25 through 32 2.2000 2.2500 2.3000 2.3500 2.4000 2.4500 2.5000 2.5500 Columns 33 through 40 2.6000 2.6500 2.7000 2.7500 2.8000 2.8500 2.9000 2.9500 Column 41 3.0000 ans = Columns 1 through 8 2.0000 1.9900 1.9802 1.9704 1.9608 1.9512 1.9418 1.9324 Columns 9 through 16 1.9231 1.9139 1.9048 1.8958 1.8869 1.8781 1.8694 1.8607 Columns 17 through 24 1.8521 1.8437 1.8353 1.8270 1.8187 1.8106 1.8025 1.7945 Columns 25 through 32 1.7866 1.7788 1.7711 1.7634 1.7558 1.7483 1.7408 1.7334 Columns 33 through 40 1.7261 1.7189 1.7118 1.7047 1.6977 1.6907 1.6839 1.6771 Column 41 1.6703


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有