Ok, I have a second order ODE and I need to solve it using Runge-Kutta 4. I know that I have to make it into 2 first order equations.
So what I have is x''+1.14x'+3.14x=2.14cos(t)
I make this look like...
my step size is h=1.
and i am going from t=0 to t=5
initial conditions are x(0)=1 and x'(0)=0
I can solve this by hand on paper, however I am not too clear on how to write this out in MATLAB. Any help with the coding is greatly appreciated.
No products are associated with this question.
You can use ode45. You first define a function for your differential equation
function dy = myode(t,y) dy = zeros(2,1); dy(1) = y(2); dy(2) = 2.14*cos(t)-1.14*y(2)-3.14*y(1);
then you can call ode45 with your initial conditions
[T,Y] = ode45(@myode,0:5,[1;0])