function result = damped_mod_sol(C,K,t_vector,IC) % Solution to damped spring-mass-dashpot system % Computes the solution to the damped spring-mass-dashpot system % C = c/m, where c is the damping coefficient and m is mass % K = k/m, where k is the spring constant and m is mass % t_vector, time values % IC = initial conditions, where IC(1) = initial displacement and % IC(2) = initial velocity % result is a matrix consisting of displacement in column 1 and % velocity in column 2 % Matlab ODE solver computes the solution to the damped % spring-mass-dashpot system [t,z] = ode23('damped_spring_mass',t_vector,IC,[],C,K); result = [z(:,1),z(:,2)]; % z(:,1) - displacement, z(:,2) - velocity