ODE45 for Second Order
Mostra commenti meno recenti
I have this second order ODE I am trying to solve w.r.t t (i.e d^2y/dt^2)
y'' = A/R[1-(1/c^2*(y')^2)]^1.5.
The initial value of y ( i.e y(0)) is a vector and y'(0) is a constant. Quantities A, R, and c are constants. I reduced it to a first order ODE as
y(1)' = A/R[1-(1/c^2*(y(1))^2)]^1.5
where y(1) = y' and wrote the script below:
A = 1.345e+8;
y0 = [0:10:2.5e-3];
y(1) = 2.5e-3;
c = 3e+4;
f = @(t,y) [y(2);((A/y)*(1-(y(1)/c^2)))];
tSpan = [0:10:50];
[t,y] = ode23(f,tSpan,y0)
but I keep getting an error. Please, what I did wrong? Thanks.
Risposte (1)
James Tursa
il 6 Giu 2018
Modificato: James Tursa
il 6 Giu 2018
Based on your description, I would have expected something more like this for the derivative:
R = 2.5e-3;
f = @(t,y) [y(2);(A/R)*(1-(y(2)^2/c^2))^1.5];
That being said, I don't follow what you mean by "y is a vector" and this initial condition:
y0 = [0:10:2.5e-3] <-- the stepping and final value don't make sense
Do you mean you want to solve this ODE independently for several different starting conditions?
5 Commenti
Shozeal
il 6 Giu 2018
James Tursa
il 7 Giu 2018
Try y0 = [0;100] to get one of the solutions. To get other solutions replace y0(1) with another number and make another run.
Shozeal
il 14 Giu 2018
James Tursa
il 14 Giu 2018
plot(t,y(:,1));
Shozeal
il 14 Giu 2018
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!