Question: (g) Use the provided MATLAB code to integrate the equations of motion numerically. Experiment with various integration step- sizes. Produce plots of x(t) vs t

(g) Use the provided MATLAB code to integrate the equations of motion numerically. Experiment with various integration step- sizes. Produce plots of x(t) vs t and v(t) vs t. (h) Using MATLAB plot the analytical solutions for x(t) and v(t) found in part (e) vs. the numerical solutions for x(t) and v(t) found in part (g).
% Begir clear close all % initial time t0 = 0; % final time t1 = 5; % time step dt = 0.01; number of points on time axis n = (t1 - t0)/dt; initial conditions % initialize variables for i = 1:n %SHM k=1; m=1; F = -k*x; a= F/m; % Free Fall with Aerodrag kd .81 Kd* = 1; g = 9.81; a = F/m; t = t + dt ; x = x + v*dt; % use updated velocity for better accuracy tarray = [tarray, t]; varray = [varray-v] ; end subplot (211),plot (tarray..xarray, 'LineWidth',2) xlabel('Time (s)) label.(* Displacement (m)') grid subplot (212),plot (tarray.varray, 'LineWidth',2) xlabel('Time (s)') ylabel( 'Velocity (m/s)') grid % Finish
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
