如何用matlab求解方程集的eulers积分

时间:2017-04-19 17:01:13

标签: matlab

the sets of equations

我基本上尝试使用ode45但收到错误:

Warning: Failure at t=1.570741e+00. Unable to meet integration tolerances
without reducing the step size below the smallest value allowed (3.552714e-15)
at time t.

欧拉集成区的初始条件如下: h = 0.25, t = 0, x[0] = 0 , x[1] = 2, x[2] = 10

我的代码是

tuto.m

function dx=tuto(t,x)

dx1=x(1)^2+1;

dx2=t*sin(x(1)+x(2));

dx3=sin(cos(x(1))+sin(x(3)));

dx=[dx1;dx2;dx3];

的main.m

% To solve the system of equations dx1/dt=x2; dx2/dt=-x11
% It uses the file tuto.m

clear all % Clear all

t=[0 30]; % Time span

xinit=[0;2;10]; % Initial condition

[t,x]=ode45(@tuto,t,xinit); % Integrate equations

%plot(t,x(:,1)) % Plot x1 vs t

%title('CFB'); xlabel('t'); ylabel('x1');

%plot(t,x(:,2)) % Plot x2 vs t

%title('CFB'); xlabel('t'); ylabel('x2');

%plot(t,x(:,3)) %plot x3 vs t

plot3(x(:,1),x(:,2),x(:,3)) % Plot x2 vs x1

%title('CFB'); xlabel('x1'); ylabel('x2)');

1 个答案:

答案 0 :(得分:0)

如果我在t = [0:0.25:30]中包含h = 0.25;错误消失了运行主脚本。我也可以获得正确的图形。