DOC PREVIEW
UCCS ECE 2610 - Introduction to MATLAB

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

IntroductionManipulating Sinusoids with MATLABTheoretical CalculationsRepresentation of Sinusoids with Complex ExponentialsConclusionAppendix A: MATLAB CodeECE2610 Lab 1: Introduction to MATLABStudent Name - 1 - 08/04/10 ECE2610: Introduction to Signals and SystemsLab 1: Introduction to MATLABUCCSStudent NameECE2610 Lab 1: Introduction to MATLABIntroductionThe purpose of this lab is to provide an introduction to MATLAB. The exercises in the first two sections ofthe lab step through the basics of working in the MATLAB environment, including use of the help system,basic command syntax, complex numbers, array indexing, plotting, and the use of vectorization to avoidinefficient loops. The first two sections of the lab exercise are not covered in this report. The thirdsection of the lab involves the use of MATLAB for the manipulation of sinusoids, and is the topic of thislab report. Manipulating Sinusoids with MATLABThree sinusoidal signals have been generated in MATLAB. The signals have a frequency of 4KHz, and havebeen generated over a duration of two periods. The first two signals, x1(t) and x2(t), aredescribed by the following expressionsx1(t)= A1cos(2 π(4000)(t−tm 1))(1)x2(t)= A2cos(2 π(4000)(t−tm2))(2)The amplitudes and time shifts are functions of your age and date of birth as described below.A1=my age=36A2=1.2 A1=43.2(3)The time shifts are defined astm1=(37.2M)T =(37.27)250 μsec=1.3 msectm2=−(41.3D)T =−(41.317)250 μsec=−607.35 μsec(4)where M=7 is my birth month, D=17 is my birth day, and T =1/f =250 μsec is the periodof the 4KHz sinusoidal signals.The third sinusoid, x3(t), is simply the sum of x1(t) and x2(t).x3(t)=x1(t)+x2(t)(5)The time vector, t, used to generate the signals has been generated with the following lines ofMATLAB code.f = 4e3; % sinusoid freqT = 1/f; % period (250 usec)tstep = T/25; % time stept = -T:tstep:T; % time vectorThe time vector, t, ranges from – T, or one period prior to t=0, to T, or one period aftert=0. The time step variable, tstep, controls the number of samples that are generated perperiod of the signal, in this case 25 points per period.Student Name - 2 - 08/04/10ECE2610 Lab 1: Introduction to MATLABThe signals defined by equations (1), (2), and (5) are plotted in Figure 1.Figure 1. Plots of the three sinusoidal signals generated in MATLAB.Theoretical CalculationsThe amplitudes and time shifts of the three sinusoids have been measured and annotated on the plotshown in Figure 2. The time shift values, tmi, can be used to calculate the phase of each signal asfollows.ϕ1=−tm1T∙ 2 π =−78.6 μsec250 μsec∙2 π=−1.97 radians(6)ϕ2=−tm2T∙ 2 π =−−107.4 μsec250 μsec∙2 π=2.7 radians(7)Rewriting the expressions for x1(t) and x2(t) using the phase values calculated in (6) and (7)yieldsx1(t)=36 cos(2 π(4000)t−1.97)(8)x2(t)=43.2 cos(2 π(4000)t+2.7)(9)Student Name - 3 - 08/04/10ECE2610 Lab 1: Introduction to MATLABFigure 2. The three sinusoids with the amplitude and time shift of each annotated on the plot.Also shown in Figure 2 are the amplitude and time shift values for x3(t). These values were measureddirectly from the Figure 2 plot as A3=55 and tm 3=115 μsec, respectively. The time shift valuecan be used to calculate the phase of x3(t) as follows.ϕ3=−tm3T∙ 2 π =−115 μsec250 μsec∙ 2 π =−2.89radians(10)As an alternative to measuring the amplitude and phase of x3(t) graphically, the phasor additiontheorem can be used to calculate these values. Expressed in complex exponential form, the first twosinusoids arex1(t)=ℜ{A1ej ϕ1ejωt}=ℜ{36 e− j1.97ej 2 π ∙4000 t}(11)x2(t)=ℜ{A2ej ϕ2ejωt}=ℜ{43.2 ej 2.7ej 2 π ∙ 4000 t}(12)The third sinusoid, x3(t), can then be expressed as the sum of (11) and (12).x3(t)=ℜ{(A1ej ϕ1+ A2ej ϕ2)ejωt}=ℜ{A3ej ϕ3ejωt}(13)Student Name - 4 - 08/04/10ECE2610 Lab 1: Introduction to MATLABSubstituting in values for A1, A2, ϕ1, and ϕ2, and solving for A3 and ϕ3 yieldsx3(t)=ℜ{A3ejϕ3ejωt}=ℜ{55.1e−j 2.87ejωt}(14)The calculated amplitude and phase values of A3=55.1 and ϕ1=−2.87 given in (14) agree veryclosely with the values obtained through graphical measurement. The phase values differ slightly due tothe difficulty of identifying the exact time of the signal peak from the graph.Representation of Sinusoids with Complex Exponentials Signals can alternatively be generated in MATLAB by using the complex amplitude representation. Forexample, the expression for x1(t) given in (11) can be used to generate the signal in MATLAB asshown in the following code segment.A1 = 36; % amplitudephi1 = -1.975; % phase in radiansx1 = real(A1*exp(1j*phi1).*exp(1j*2*pi*4000*t));The signal resulting from these lines of code is plotted in Figure 3. Comparing Figure 3 to the top strip inFigure 1 clearly shows that x1(t) generated using the complex amplitude representation is equivalentto x1(t) generated using the real-valued cosine function.Figure 3. Sinusoidal signal, x1(t), generated using the complex amplitude representation.ConclusionThis lab exercise has provided an introduction to the fundamentals of MATLAB. The third section of thislab, which has been detailed in this report, explored the use of MATLAB to generate sinusoidal signals.Three sinusoidal signals have been generated in MATLAB, the third of which was a sum of the other two.The phasor addition theorem has been employed to calculate the resulting amplitude and phase of theStudent Name - 5 - 08/04/10ECE2610 Lab 1: Introduction to MATLABsummed signal. Additionally, it has been demonstrated that sinusoids can be equivalently generated inMATLAB using the complex exponential representation for those signals.Student Name - 6 - 08/04/10ECE2610 Lab 1: Introduction to MATLABAppendix A: MATLAB Code% lab1_3.m% ECE2610% Lab 1% Kyle Webb% 8/4/10 clear all f = 4e3; % sinusoid freqT = 1/f; % period (250 usec)tstep = T/25; % time stept = -T:tstep:T; % time vector A1 = 36; % amplitude of x1 (age)A2 = 1.2*A1; % amplitude of x2 M = 7; % birth monthD = 17; % day of birthtm1 = (37.2/M)*T; % time shift for x1tm2 = -(41.3/D)*T; % time shift for x2 % generate the sinusoidal signalsx1 = A1*cos(2*pi*f*(t-tm1));x2 = A2*cos(2*pi*f*(t-tm2));x3 = x1 + x2; A1t = A1*ones(1,length(t));A2t = A2*ones(1,length(t)); %


View Full Document

UCCS ECE 2610 - Introduction to MATLAB

Download Introduction to MATLAB
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Introduction to MATLAB and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Introduction to MATLAB 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?