Homework #3 (due Oct 9)

advertisement

ENGR 518 Homework #3

Due Tuesday 10/9/2012

For several of these problems, it may be helpful to use Matlab’s fft command, and begin with the following code to set up time and frequency vectors: fs = (whatever the sample frequency is) ;

N = (the number of points recorded, such that the measurement period T=N/fs) ; dt=1/fs; % the time step between samples t=(0:N-1)*dt; % a vector of N properly spaced times f=(0:N-1)*(fs/N);% a vector of N frequencies

Note that this gives enough frequencies to plot a two-sided spectrum, i.e, the Nyquist frequency will be in the middle of the f vector. To plot a one-sided spectrum, use only the first half of f .

1.

Consider a rectified 5 Hz sine wave, x ( t )

= sin(10

x p t )

, as shown at right. Calculate the temporal mean , the RMS value, and the RMS value of the AC component (i.e., of

x

x ). You can either integrate the analog signal (over some integer number of cycles) or create a series of x values (and reasonably finely spaced time increments) and use the summation formulas for discrete signals.

2. Consider the following two signals: a simple sinusoid at 2

Hz (that is,

x

( t )

= sin 4 p t

) and a square wave at 2 Hz (that is, y ( t )=1 for the first and third quarter of each second and y ( t )

= -

1

for the second and fourth quarter of each second). Using each of the following combinations of sample frequency and measurement period, create a series of x and y values representing these signals, and then calculate and plot the magnitude of the discrete Fourier transform (properly scaled as a single-sided peak amplitude spectrum). a) sampled at f s

= 10 Hz, measured for T = 2 seconds ( N = 20 samples) b) sampled at f s

= 25 Hz, measured for T = 2 seconds ( N = 50 samples) c) sampled at f s

= 25 Hz, measured for T = 5 seconds ( N = 125 samples) d) sampled at f s

= 100 Hz, measured for T = 5 seconds ( N = 500 samples)

Hint: to convert the double-sided DFT to a single-sided DFT, you can simply double all the magnitudes (except the zero-frequency coefficient) and plot only the first half of each vector.

3. Consider a measured signal of the form x ( t )

=

20 e

-

50 t cos(86.6

t )

, as shown at right. Generate two series of values corresponding to two measurements of this signal, both sampled at 100 Hz, but one lasting 20 samples (0.2 seconds) and the other lasting 50 samples

(half a second). Plot the peak amplitude frequency spectrum (magnitude of the scale discrete Fourier

transform) for both series of measured data and comment on the reasons for the differences between the two plots.

4. Consider a sinusoidal signal of amplitude 10 V and frequency 10 Hz, corrupted by random noise. Create a series of values representing this signal sampled for 5 seconds at 100 Hz, using the following Matlab code or equivalent: fs=100; N=500; dt=1/fs; t=(0:N-1)*dt; f=(0:N-1)*(fs/N); x=10*sin(20*pi*t)+2*randn(size(t));

Calculate and plot both the power spectrum and the power spectral density for this signal, and observe that the noise has roughly equal level across all frequencies, while the power in the sinusoid stands out as a peak at 10 Hz.

Then, perform the same calculate using only the first 0.5 seconds of the data (the new frequency vector should include every 10 th entry from the original frequency vector). Plot the resulting power spectrum and power spectral density on the same two sets of axes as the original curves, and comment on the effects of using the shorter data set for both ways of scaling the spectrum. It may be helpful to use log scale for the vertical axes in these plots.

5. Consider a sinusoidal signal of frequency 2 Hz, corrupted by a modest amount of random noise. Create a series of values representing this signal sampled for 5 seconds at 1000 Hz, using the following Matlab code or equivalent: fs=1000; N=5000; dt=1/fs; t=(0:N-1)*dt; f=(0:N-1)*(fs/N); x=sin(4*pi*t)+0.2*randn(size(t));

Plot the signal and the magnitude of its frequency spectrum (it may helpful to use log-log axes for the frequency spectrum). Then, a) Obtain the derivative of the signal by multiplying the coefficients of the discrete

Fourier transform by the appropriate values (see hint below). Plot the resulting spectrum and then take the inverse DFT and plot the resulting time-domain signal (it should be very noisy). b) Apply a digital low-pass filter to the signal (choose an appropriate cutoff and filter order to obtain reasonable results). Plot the resulting filtered time-domain signal.

Hint: to calculate the derivative, the Fourier coefficients

X k

must be multiplied by i 2 p D f k for the first half ( k up to N /2). For the second half, the k ’s are actually negative and counting back towards zero. A vector of appropriate factors can be obtained using the following:

[f(1:N/2) -f(N/2:-1:1)]

Download