Hello, I am fairly new to Matlab. I am trying to use matlab to solve an ODE with known boundary conditions and plot the results against those I've obtained analytically. The ODE in question is
d^2y/dt^2 + 400y = 0
For t 0-5 seconds and initial displacement y(0)=0.1 and velocity dy/dt=0. Since it has a second derivative, my understanding from reading so far is that I need to rewrite it as a sytem of equations with only first order derivatives. So subsituting y(1)=y(t) and y(2)=dydt, I tried using this code that I found,
function dydt = odefun(t,y)
dydt = zeros(2,1);
dydt(1) = 0*y(1)+y(2);
dydt(2) = -400*y(1)+0*y(2);
But it says that I don't have enough input arguements. I added in the 0* terms in hopes of correcting that, but no luck. I'm thinking maybe its asking for a t domain, but I tried a couple ways of defining that without sucess. I also played around with a couple alternative codes but no dice there either. I'm thinking if I get this ODE function to work, I insert it into ODE45 solver and plot the results. Thanks in advance for any help.