在使用ode45
求解一组 ODE 之后,我想编写一个 Matlab 函数,以初始条件 x_0 作为输入,并给出时间 T 的最终状态 x_1 作为输出,从而创建一个离散动力系统 f。
但是,我在编写将嵌入初始条件、ode45
求解器和最终状态作为输出的函数时遇到了一些麻烦。
我的尝试:
% F is the function handle to the set of ODEs to be solved
x_0 = some initial conditions here
T = 10
function x_1 = f(x_0);
[t, y] = ode45( F, [0 T], x_0 );
% store final state values in variables
x_final = y( end, 4 );
y_final = y( end, 5 );
theta_final = y( end, 3 );
% now define the output of f to take the above final state values
x_1 = [ x_final y_final theta_final ];
end
这似乎不起作用。我收到以下消息:
(1) 函数“f”可能未被使用
(2) 此处分配给“t”的值似乎未使用。考虑用〜替换它。
我错过了什么?
谢谢,