%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Compute velocity of simple system %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% v0 = 2; % initial velocity m = 1; % mass c = 0.1; % friction coefficient tspan = [0 5]; % time boundaries global alpha alpha = c/m; [t,v] = ode45('f1',tspan, v0); plot(t,v); xlabel('time in s'); ylabel('velocity in m/s'); title('simple velocity profile'); %Since in this particullar case, we know explicit solution %let's see how accurate matlab is: v_th = v0*exp(-alpha*t); diff = v-v_th;