I am very new to scilab and am trying to understand how ODE works for second order ODE works in SCILAB.
My Equation is: (d^2y)/(dt^2 )+2 dy/dt + y=0
I would like to plot the results. So far I have understood I need to break down the equations in to two first order equations. So the program must look like:
function dx=f(x, y)
dx(1)=2*y+1;
dx(2)=y;
endfunction
Can you check if this is correct, I am not sure if dx(1)
and dx(2)
is correct.
Thank you.
If x_1 is y and x_2 is dy/dt you would rather write your ode right hand side (i.e. dx/dt) like this
function dxdt=f(t, x)
dxdt(1) = x(2);
dxdt(2) = -x(1)-2*x(2);
endfunction