All About Circuits Forum  

Go Back   All About Circuits Forum > Software, Microcomputing, and Communications Forums > Programmer's Corner


Programmer's Corner Discussion forum for all aspects of programming and software engineering. Any software programming language welcome: C, C++, C#, Fortran, Java, Matlab, etc.

Reply   Post New Thread
Thread Tools Display Modes
Old 05-11-2009, 05:16 AM
ethan007 ethan007 is offline
Junior Member
Join Date: May 2009
Posts: 10
Default Design signal in Matlab

  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)/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;
  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
Signature Links Deleted.
Reply With Quote
Old 05-12-2009, 02:36 PM
etuzuner's Avatar
etuzuner etuzuner is offline
Junior Member
Join Date: Mar 2009
Location: Bursa, TURKEY (GMT+03:00)
Posts: 23

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".

Reply With Quote
Old 05-12-2009, 02:50 PM
beenthere's Avatar
beenthere beenthere is offline
Senior Member
Join Date: Apr 2004
Location: Missouri, USA (GMT -6)
Posts: 15,815
Blog Entries: 10

This has been moved from -

Please do not hijack existing threads.
First comes the hardware, then the software.
Reply With Quote
Reply   Post New Thread

, ,

Related Site Pages
Section Title
Worksheet Active filters
Worksheet Signal modulation
Worksheet Passive filter circuits
Worksheet Mixed-frequency signals
Textbook Resonant filters : Filters
Textbook Band-stop filters : Filters
Textbook Band-pass filters : Filters
Textbook High-pass filters : Filters
Textbook Low-pass filters : Filters
Textbook What is a filter? : Filters

Similar Threads
Thread Thread Starter Forum Replies Last Post
matlab help , Digital signal processing dina Programmer's Corner 40 03-23-2009 07:21 PM
Useful Matlab Information Dave Programmer's Corner 7 11-09-2008 05:51 AM
DTMF signal through an electricity 220V 50Hz kirill2008 The Projects Forum 11 09-24-2008 02:51 AM
MATLAB - Digital Signal Processing lamerooze Programmer's Corner 0 03-13-2008 06:08 PM
MATLAB, retrieve voice signal corrupted by awgn? makyboy Programmer's Corner 3 05-25-2007 10:14 PM

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 02:15 PM.

User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License.
Powered by vBulletin
Copyright ©2000 - 2014, vBulletin Solutions, Inc.