- Create a signal by typing the following at the Matlab prompt: % Sample rate in Hertz
fs = 256;
% Number of samples of the signal
NumSamples = 10^4 + 1;
% Define a time vector
t = [-(NumSamples-1)/2NumSamples-1)/2].'/fs;
% "Cut off" frequency of signal
fco = 4;
% Create a sinc function
x = 2*sin(2*pi*fco*t)./t;
x((NumSamples+1)/2) = 2*2*pi*fco;
% Chebyshev window for spectral shaping
win = chebwin(NumSamples,80);
% Apply the window
x = x.*win; - Write a function for computing and displaying the spectrum of this signal or download sigspec.m
- Display the spectrum of the signal x. The figure below shows the magnitude spectrum in linear and logarithmic formats.
- Since demodulation involves low-pass filtering, we will learn how to use a function for designing low-pass filters. Remez is a convenient function for designing low-pass filters and is implemented in Matlab. The syntax is:
- N is the filter order. The length of the filter will be N+1.
- F=[0, fpass, fstop, (fs/2)]/(fs/2) is a vector containing the critical frequencies of the filter: fpass is the upper edge of the pass band, fstop is the lower edge of the stop band, and fs is the sample rate at which the filter will be used.
- A=[1, 1, 0, 0] is a vector that tells what the gain of the filter should be at the critical frequencies specified in the F vector. For example, A=[2, 2, 0, 0] will give a gain of two in the pass band.
- W=[wpass, wstop] is a vector of weights that controls the ripple in the pass and stop bands and is an optional argument. The default is W=[1, 1]. If the stop band attenuation is not sufficiently low, set W=[1, 10].
- Design a low pass filter with 31 taps with pass and stop band edges at 4 and 60 Hz, that will filter a signal sampled at a rate of 256 samples per second. The filter should have a gain of two in the pass band and use the weight vector W=[1, 10]. Using your function for computing and displaying signal spectra, plot the frequency response of the filter you designed. Linear and log magnitude plots of the filter frequency response are shown below.
- In Simulink, build a simple AM modulator and synchronous demodulator using a cosine carrier with carrier frequency 32 Hz. Modulate the signal x created above. The highest frequency in x is 4 Hz. Design an appropriate low-pass filter for the demodulator using the remez function as described above. Use a sample rate of 256 Hz for the simulation. A block diagram illustrating the modulator and demodulator is shown below
- I recommend using "Signal From Workspace", "Signal To Workspace", and "Sine Wave" blocks from the Signal Processing Blockset library. The "Discrete Filter" block is in the Discrete library and the "Product" block can be found in the Math Operations library.
- Double click on a block to configure its parameters.
- Display the spectrum of the signals at each point in the modulator/demodulator. The two figures below illustrate the spectra using linear and log magnitude plots.
- The first plot of the five shows the spectrum of the original signal. Use the zoom feature in the figure window to verify that the highest frequency is 4 Hz.
- The second plot illustrates the spectrum of the cosine carrier which consists of a pair of "impulses".
- The third plot shows the spectrum of the modulated signal. Does it have have the amplitude of the original spectrum?
- The fourth plot shows the low pass filter response superimposed on top of the spectrum of z. As expected, the spectrum of z consists of three replicas of the original spectrum. Do these replicas have the correct scaling?
- The fourth plot also shows that the low pass filter attenuates the double frequency components by about 75 dB.
- The fifth plot shows that the original spectrum is recovered (with negligible distortion) after low pass filtering.
- List the information you gave to the remez function to design the low-pass filter for your demodulator. What is the stop band attenuation and the pass band gain of the filter you designed (see the log magnitude frequency response).
- Plot the spectra of the signals and the low-pass filter (linear and log magnitude) as illustrated above.
- Explain why the spectra of the demodulator output does not match exactly the original spectrum (see the log magnitude spectrum).
- Explain why the spectrum of the carrier in the log magnitude plot is not exactly a pair of delta functions
- Hope THIS WILL BE HELP FULL