したがって、初期条件 x(0)= 0 および v(0) = x'(0) = v_o = 1 で x''(t) = -x(t)^p を解く必要があります。パラメーター 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) odeearguments の使用エラー (91 行目) ODE_OSCILLATION/OSCILATION_EQUATION は列ベクトルを返さなければなりません。
ode45 のエラー (114 行目) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
ode_oscillation のエラー (17 行目) [t,velocity,x] = ode45(@oscilation_equation, tspan,1);