Поэтому мне нужно решить x '' (t) = -x (t) ^ p с начальными условиями x (0) = 0 и v (0) = x '(0) = v_o = 1. Значение параметра p равно 1.
Вот что у меня есть:
function [t, velocity, x] = ode_oscilation(p)
y=[0;0;0];
% transform system to the canonical form
function y = oscilation_equation(x,p)
y=zeros(2,1);
y(1)=y(2);
y(2)=-(x)^p;
% to make matlab happy we need to return a column vector
% so we transpose (note the dot in .')
y=y.';
end
tspan=[0, 30]; % time interval of interest
[t,velocity,x] = ode45(@oscilation_equation, tspan, 1);
t = y(:,1);
xposition=y(:,3);
velocity=y(:,2);
end
и это сообщение об ошибке, которое я получаю:
ode_oscillation (1) Ошибка при использовании аргументов odearguments (строка 91) ODE_OSCILLATION / OSCILATION_EQUATION должен возвращать вектор-столбец.
Ошибка в ode45 (строка 114) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Ошибка в ode_oscillation (строка 17) [t, скорость, x] = ode45 (@oscilation_equation, tspan, 1);