All About Circuits Forum Design signal in Matlab
 Register Blogs FAQ Members List Today's Posts Search Today's Posts Mark Forums Read

 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.

#1
05-11-2009, 05:16 AM
 ethan007 Junior Member Join Date: May 2009 Posts: 10
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
18. Hope THIS WILL BE HELP FULL
__________________
#2
05-12-2009, 02:36 PM
 etuzuner 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".

Regards
#3
05-12-2009, 02:50 PM
 beenthere Senior Member Join Date: Apr 2004 Location: Missouri, USA (GMT -6) Posts: 15,815 Blog Entries: 10

__________________
First comes the hardware, then the software.

 Tags design, matlab, signal

 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 dina Programmer's Corner 40 03-23-2009 07:21 PM Dave Programmer's Corner 7 11-09-2008 05:51 AM kirill2008 The Projects Forum 11 09-24-2008 02:51 AM lamerooze Programmer's Corner 0 03-13-2008 06:08 PM makyboy Programmer's Corner 3 05-25-2007 10:14 PM

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Electronics Forums     General Electronics Chat     The Projects Forum     Homework Help     Electronics Resources Software, Microcomputing, and Communications Forums     Programmer's Corner     Embedded Systems and Microcontrollers     Computing and Networks     Radio and Communications Circuits and Projects     The Completed Projects Collection Abstract Forums     Math     Physics     General Science All About Circuits Commmunity Forums     Off-Topic     The Flea Market     Feedback and Suggestions

All times are GMT. The time now is 01:29 PM.