function J = damped_cost_func(q,t,data,IC) % Cost Function for the vibrating beam inverse problem % using the damped spring-mass-dashpot system % Computes the value of the cost function % q, vector of guess values for C(q(1)) and K(q(2)) % t, time % data, experimental data(acceleration values) % J, cost function value associated with q mod_sol = damped_mod_sol(q(1),q(2),t,IC); % model solution to damped model a_mod = -q(1)*mod_sol(:,2) - q(2)*mod_sol(:,1); % acceleration data from the damped model J = (1/length(data))*sum((abs(a_mod-data)).^2); % cost function