Keep Getting This Error : @(T,X)SECOND_ORDER(T,X,A0,A1) must return a column vector.
Afficher commentaires plus anciens
Hello all! I'm trying to solve the second order equation y'' + a1*y' + a0*y = 0 using ode45 and I've gotten stuck and keep getting the same error. My current code:
%%Behavior of second order ODEs
% y'' + a1*y' + a0*y = 0
% x' = Ax
N=1000;
T=10;
t = linspace(0,T,N); % initialize the time vector
a0=0;
a1=0;
x0=2; %y
x1=0; %dy
x=[x0;x1];
dy = second_order(t,x,a0,a1);
%ODE
[t,x] = ode45(@(t,x)second_order(t,x,a0,a1),t,x0);
plot(t,x,'k-','LineWidth',2);
My Function:
function [ dx ] = second_order(t,x,a0,a1 )
A=[0,1;-a0,-a1];
dx= A*x;
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!