L this is an individual report). SuIts and all lat Is shown beginning on page 4-
ID: 2262111 • Letter: L
Question
Explanation / Answer
function X = SMD(B, t, m) % ‘SMD’ for ‘Spring-Mass-Damper’ % B = parameter and initial conditions column vector (unless you want to % supply the initial conditions in this function rather than passing % them as parameters). X0 = B(3:4); % This gives you the option of passing the last two entries of the % parameter vector as the initial values of your ODE. In this case, the % curve-fitting function will also fit the initial conditions as well as % Kd and Ks. If you don't want the initial conditions to be parameters, % B becomes [2 x 1] and you define X0 as whatever you like in the % function. [T,X] = ode45(@DifEq, t, X0); function xdot = DifEq(t, x) % B(1) is the coefficient of viscous friction (‘damper’), Kd; % B(2) is the spring constant, Ks; xdot = zeros(2,1); xdot(1) = x(2); xdot(2) = -x(1)*B(2)/m -x(2)*B(1)/m; end X = xdot(:,2); % Assumes ‘xdot’ is a [N x 2] matrix where N = length(t) end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.