Data were taken with a Data Acquisition System (DAQ) and stored in the data file 'data.txt'. 'data.txt' is a text file with 3 columns containing the following data:
Column 1: Time [s]
Column 2: Voltage [V]
Column 3: Laser Doppler Vibrometer (LDV) velocity signal [mm/s]
Load the data into Matlab (use the 'load' command), and create one figure with (2x2) subplots. Plot the following data:
1. In the 1st subplot (upper left corner), plot channel 2 in mV versus time in ms
2. In the 2nd subplot (upper right corner), we want to plot the moving average of the voltage signal (channel 2) in mV versus time in ms. For the moving average calculation, compute the average value of the past 500 samples. Use a for or while-loop. Note that the moving average for the first 499 samples is equal to zero.
3. For subplot 3 (lower left corner), plot the LDV velocity signal in mm/s versus time in ms
4. In subplot 4 (lower right corner), we want to plot the integrated LDV signal in nm versus time in ms. To obtain the displacement signal in mm, integrate the LDV velocity signal by using the following command line detrend(cumsum(dataOfChannel3))/ Fs;
where Fs denotes the sampling frequency at which the data was acquired. Fs can be calculated from the time vector (column 1) via
Fs = 1/(t(2)-t(1))
where t represents the time vector. 'cumsum' computes the cumulative sum of the elements. For instance, cumsum([1 2 3]) = [1 (1+2) (1+2+3)] = [1 3 6]. 'detrend' removes the linear trend from a vector, as shown in the figure below.