所以我需要解決X ''(T)= -x(t)的^ P與初始條件X(0)= 0和v(0)= X'(0) = V_O = 1 參數p的值是1。二階DIFF等式與在Matlab
這是我有:
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,接下來,T0,T最終,tdir,Y0,F0, odeArgs,odeFcn,...
在ode_oscillation錯誤(第17行) [t,velocity,x] = ode45(@oscilation_equation,tspan,1);