writing second degree ODE
Mostrar comentarios más antiguos
Hello everyone,
I'm pretty new to matlab and writing ODE codes. I just finished my first grader project, and i want to ask a question about ODE writing.
Here is the code that was not work well;
function dYdt = racecarfun(t,Y);
Y1=Y(1);
Y2 = Y(2);
Y3=Y(3);
dY1dt=Y2;
dY2dt=Y3;
F = 4000.0; % force on car, [N]
m = 1300.0; % mass of car, [kg]
A = 3.0; % frontal area, [m^2]
Cd = 0.6; % drag coefficient, [-]
rho = 1.23;
dY3dt=((F-(Cd*rho*A*0.5*Y2.^2))/m);
dYdt=[dY1dt;dY2dt;dY3dt];
end
and here is the code i wrote after a quick search;
function dydt = racecarfun(t,y);
dydt=zeros(2,1);
dydt(1)=y(2);
F = 4000.0; % force on car, [N]
m = 1300.0; % mass of car, [kg]
A = 3.0; % frontal area, [m^2]
Cd = 0.6; % drag coefficient, [-]
rho = 1.23;
dydt(2)=((F-(Cd*rho*A*0.5*y(2).^2))/m);
end
In the first one, i wanted to write all x,v and a in formula however, the example goes with only v and a in the second one. I wonder what is the problem with the first code?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre PDE Solvers en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!