Mohammad N.Sabet Assoc.Prof.Erhan Ince Eastern Mediterranean University Faculty of Engineering Department of Electrical and Electronic Engineering EENG 360 Communication System I Laboratory LAB 2 SPECTRUM ANALYSIS OF PERIODIC SIGNALS General Policy: 1. No late submission will be accepted. 2. All submitted work should have a title page with student name and number. Objectives: • • To find the frequency spectrum of a square wave using MATLAB code and building blocks in SIMULINK. To synthesize a square wave from harmonics. Theory A periodic signal of frequency w0 can be synthesized from sine waves as follows: sin Where : The peak amplitude of n-th harmonic. : The phase angle of n-th harmonic. : The average dc voltage of waveform. Specifically, a square wave of peak amplitude of V volts is synthesized from: =0 = 0 n=1, 3, 5 , ……… Only odd harmonics exist in this waveform. A triangle wave of V volt peak amplitude is synthesized from, =0 = 0 n=1, 3, 5 , ……… Lab 2 3/11/2008 Mohammad N.Sabet Assoc.Prof.Erhan Ince 1. SQUARE WAVE Graph a 1 KHz pulse wave of 5 volts peak amplitude. Choose the number of points as power of two, i.e. 128, 256, 512. This selection for the number of points will help speed up the computation of signal’s Fourier Transform. MATLAB Program: V=5; %the peak voltage f0 = 1000; % Fundamental frequency in Hertz w0 = 2*pi*f0; % Fundamental frequency in radians T=1/f0; % the period of the square wave D=0.5; % pulse duty ratio % plotting a square wave dT=T/512; % incremental time, t1=0:dT:D*T-dT; % Positive half period t2=D*T:dT:T-dT; % Negative half period t=[t1 t2]; %One complete period v=V*[ones(size(t1)) -ones(size(t2))]; % square wave signal over a period plot(t,v) axis([0 T -10 10]) %Change the scale on the figure x-axis: 0 to T, y-axis: -10 %Plotting square wave by using a built-in MATLAB function (only in MATLAB v7.0): v=V*square(w0*t); % keyword to generate a square wave in MATLAB plot(t,v) axis([0 T -10 10]) SIMULINK Program: Parameters V, T, and dT are entered in the MATLAB command window. Set the simulation stop time to T (one period only). Lab 2 3/11/2008 Mohammad N.Sabet Assoc.Prof.Erhan Ince 2. SYNTHESIZING A SQUARE WAVE FROM HARMONICS Synthesize the square wave from harmonics: (Use the Fourier Table for calculating harmonic amplitudes) (a) Fundamental. (b) Fundamental and 3rd harmonic. (c) Fundamental, 3rd and 5th harmonics. MATLAB Code for Harmonic Synthesis: % harmonic amplitudes V0=0; V1= 4*V/pi; V3= 4*V/(3*pi); V5= 4*V/(5*pi); V7= 4*V/(7*pi); V9= 4*V/(9*pi); v1 = V0+V1*sin(w0*t); % First (fundamental) harmonic v13 = v1+V3*sin(3*w0*t); % First + Third harmonic v135 =v13+V5*sin(5*w0*t); % First +Third +Fifth harmonic subplot (3,2,1) plot (t,v,t,v1) axis ([ 0 .001 -15 15]) subplot(3,2,2) plot(t,v,t,v13) axis([0 .001 -15 15]) subplot(3,2,3) plot(t,v,t,v135) Lab 2 3/11/2008 Mohammad N.Sabet Assoc.Prof.Erhan Ince (d) Write the instructions to add the 7th harmonic to obtain the v1357 waveform. Plot the new waveform as the subplot #4 in the matrix of six figures. Note that the calculation of v1357 waveform must be completed before subplot instructions. (e) Write the instructions to add the 9th harmonic to obtain the v13579 waveform. Plot the new waveform as the subplot #5 in the matrix of six figures. Note that the calculation of v13579 waveform must be completed before subplot instructions. (f) ) Write a program to add Fundamental to 99th harmonic and display the resulting waveform. Add following lines to your MATLAB program before subplot instructions: v99=0; %synthesized square wave % add only odd harmonics. for n=1:2:99 v99 = v99+(4*V/(n*pi))*sin(n*w0*t); end Then add a subplot #6 as follows : subplot(3, 2, 6) plot(t,v99) axis([0 .001 -15 15]) The plots are shown below: Lab 2 3/11/2008 Mohammad N.Sabet Assoc.Prof.Erhan Ince SIMULINK Program: Harmonic amplitudes V0, V1, V3, V5, V7, V9, T, and f0 are used from the MATLAB command window. Use sample time as either 0 or T/100 in all blocks. Set the simulation stop time to T seconds. Lab 2 3/11/2008 Mohammad N.Sabet Assoc.Prof.Erhan Ince 3. FREQUENCY SPECTRUM Type in MATLAB function freqspectrum(x,f0,M) shown below. The input arguments for the function are: %x is the waveform array in time %f0 is the fundamental frequency %M is the number of harmonics to be displayed function [y, f] = freqspectrum(x,f0,M), N=size(x,1); %number of elements in the waveform array x, it should be (2 power m) f=0:f0:f0*(N-1); %frequency array y1=fft(x); % FFT operation y=2*abs(y1)/N; % the peak amplitude of harmonics y(1)=y1(1)/N; % The height of the first element in the spectrum stem(f,y); % the spectrum plot axis([0,f0*M,0,1.2*max(y)]); Then call the function in the command window as follows: Clf %clear graph [vfn, f] = freqspectrum(squarewave1,f0,20); Where vfn is the peak harmonic amplitude of the n-th harmonic and f is the array of the 20 harmonic frequencies. The result is shown below: Assignment Duration:Strictly One Week Triangle wave :Repeat all above parts for a triangle wave of frequency 1 Hz and a peak-peak amplitude of 10 volts. References 1. L.Couch,Digital and Analog Communication System, Prentice Hall,2001 2. http://www.merrillvillechoir.com Lab 2 3/11/2008
© Copyright 2026 Paperzz