马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
本帖最后由 牛小贱 于 2014-3-29 21:21 编辑
我做了两个function去解这个方程。大侠们,看这么做对吗?- function [x, y, yInt] =odeSolver()
- rhs = odeSolver(x,z)
- %
- % Input
- % z: solution variable
- % x: derivative variable
- %
- % Output:
- % rhs: right hand side of the ODE
- % dz/dx = F(z,x)
- rhs = cos(x);
- The second one.
- function dzdx =ODErhs(x,z)
- %
- % Input:
- % z: vector variable
- % x: position
- %
- % Output:
- % dzdx: RHS of the ODE system
- dzdx = [z(2);z(3); x*z(1)*z(2)+0.8];
- The third one.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % question7 ODE
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Clear memory and screen
- clear all; clc
- % Data ----------------------------------------
- % Interval
- a = 0.8;
- b = 4.3;
- % Initial condition
- Z0 = [0.1376 0.204 -6952];
- % Computations --------------------------------
- % Solve the ODE
- sol = ode45(@ODErhs, [a,b], Z0);
- % Output --------------------------------------
- plot(sol.x, sol.y(1,:))
- xlabel('x')
- ylabel('y')
- title('question 7ode')
复制代码还有就是X,Y两个量的近似解我搞出来了,可是我不懂怎么去求这个 yint。 yint是一个以实数形式表示的“y的近似解的积分” 原版英文题目解释是这样的。 A real number representing the integral of the approximate solution in the interval where the differential equation has been solved. 有大侠会吗? 求救。 感恩。
|