Contents
Quarter Car ODE file
The derivative is the output and the time and present time step state vector are the inputs.
function [x_dot] = Lab1_eqns(t, x)
Global variables that are assigned originally in the master file
global A B v_in dt g
Set the input
The time index is solved for based on the present simulation time and then the input vector, u, is created. g is a constant, but the v_in value will update at each time step.
t_ind = round(t/dt + 1); u = [v_in(t_ind); g];
State derivate computation
The time derivative is computed using the state space equations.
x_dot = A*x + B*u;
end % end the function