Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For the mechanical system above, write a MATLAB code to plot the response x(t) f

ID: 1856819 • Letter: F

Question

For the mechanical system above, write a MATLAB code to plot the response x(t) for the following inputs: A step input of 0.1 meters of zero 1C. A half sine input and zero IC A sine function y(t) = sin (omega t) x 1(t) with omega = 1 rad/sec and zero 1C. Use: m = 10 Ns2 / m c = 20 Ns / m k = 50 N / m Plot the response for 10 seconds. The MATLAP code (m-file) must generate 3 different plots, i.e. for the 3 type of inputs. The plots must have a title and axis labels. You will need to use the following MATLAB functions: tf, step, lsim, title, grid, etc.

Explanation / Answer

% swanalmain.m - matlab program for simulated sine-wave % analysis on the simplest lowpass filter: % % y(n) = x(n)+x(n-1)} B = [1,1]; % filter feedforward coefficients A = 1; % filter feedback coefficients (none) N=10; % number of sinusoidal test frequencies fs = 1; % sampling rate in Hz (arbitrary) fmax = fs/2; % highest frequency to look at df = fmax/(N-1);% spacing between frequencies f = 0:df:fmax; % sampled frequency axis dt = 1/fs; % sampling interval in seconds tmax = 10; % number of seconds to run each sine test t = 0:dt:tmax; % sampled time axis ampin = 1; % test input signal amplitude phasein = 0; % test input signal phase [gains,phases] = swanal(t,f/fs,B,A); % sine-wave analysis swanalmainplot; % final plots and comparison to theory