Design signal in Matlab

Thread Starter


Joined May 11, 2009
  1. 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)/2:(NumSamples-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;
  2. Write a function for computing and displaying the spectrum of this signal or download sigspec.m
  3. Display the spectrum of the signal x. The figure below shows the magnitude spectrum in linear and logarithmic formats.
  4. 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].
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. The second plot illustrates the spectrum of the cosine carrier which consists of a pair of "impulses".
  10. The third plot shows the spectrum of the modulated signal. Does it have have the amplitude of the original spectrum?
  11. 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?
  12. The fourth plot also shows that the low pass filter attenuates the double frequency components by about 75 dB.
  13. The fifth plot shows that the original spectrum is recovered (with negligible distortion) after low pass filtering.
  14. 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).
  15. Plot the spectra of the signals and the low-pass filter (linear and log magnitude) as illustrated above.
  16. Explain why the spectra of the demodulator output does not match exactly the original spectrum (see the log magnitude spectrum).
  17. Explain why the spectrum of the carrier in the log magnitude plot is not exactly a pair of delta functions


Joined Mar 21, 2009
Let's say you have a signal which is amplitude modulated. As you know, to take that signal to baseband from passband, you need to use another local oscillator. Which means that you have four replicas of your own unmodulated signal. Two of them is added at the origin and you have 3 figures. The amplitude of the origin part is twice larger than the other two parts. Here is our job to recover exactly the message signal. You need to choose a proper amplitude.

As you know, it is very difficult to create a low pass filter characteristics, especially in high frequency applications. "Raised Cosine Filter" is very useful and commonly used in practice.

As a result, the low pass filter that is used to demodulate the modulated signal is very important. If the conditions are not satisfied, some parts of the modulated signal(i.e., information) may be lost. If you're interested, you may google the definition of "Raised Cosine Filter".