second order differential equation with variable coefficient
3 views (last 30 days)
As wrote in a previous question I have to solve the equation: d^2x/dt^2= (q/m)(E/v^2)
I have wrote the following code:
q=1; m=1; v=1; E=1;
[za, xa] = ode45(rhs, [0 100], [0 0]);
and it works fine.
The problem is that E for me is a function of z that I can write as:
if (i<=10 || i>=50)
I have found an example here: http://www.mathworks.it/help/techdoc/ref/ode23.html where is shown how to solve ode with time-dependent terms, but is is about a first order problem and I'm not able to write something similar for my second order problem... could you help me?