You are on page 1of 10

Electronic and Telecommunication Engineering Danang University of Technology

LAB 1 REPORT
TA :PHAM VAN TUAN

STUDENT: TRAN LOC PARTNER: LE HUU DUY NGUYEN HUU ANH KHOA

Exercise 1

Scripts Now we are going to edit the dampedCosine.m le to create our own script le. At the top of the filele, you will see the following commands diary 'your_name_Lab1.txt' disp('NAME: your name') disp('SECTION:your section') 1. Edit the dampedCosine.m (download from link above) script and enter your name and section where indicated. Save this new version of the script as yourName_dampedCosine.m 2. Edit the script to create a second signal where the cosine with twice the period (which gives half the frequency) of the first. 3. Add to the script the commands to plot these together with the first signal on top and second on the bottom. In other words, you should have a single figure with two dierent plots, one on top and one on bottom. You will need to use subplot and plot. Save this plot as yourName_dampedCosine.fig. 4. Show the TA your dampedCosine plot. What is the period of the cosine?

CODE

diary your_nameex1 %INSERT your name and section into these display commands disp('NAME: your_name') disp('SECTION: your_section') datestr(cputime)

%dampedCosine.m produces a plot of a cosine with frequency 1 Hz, with amplitude % scaled by a decaying exponential figure x = -5:0.01:5; y2=exp(-abs(x)).*cos(pi*x); subplot(2,1,1); xlabel('time'); plot(x,y2);

ylabel('amplitude'); title('f(x)=exp(-|x|)cos(pi*x)');

NEW CODE: diary your_nameex1 %INSERT your name and section into these display commands disp('NAME: loc') disp('SECTION: lab1') datestr(cputime)

%dampedCosine.m produces a plot of a cosine with frequency 1 Hz, with amplitude % scaled by a decaying exponential figure x = -5:0.01:5; y2=exp(-abs(x)).*cos(pi*x); subplot(2,1,1); plot(x,y2); xlabel('time'); ylabel('amplitude'); title('f(x)=exp(-|x|)cos(pi*x)');

grid on subplot(2,1,2); y1=exp(-abs(x)).*sin(0.5*pi*x);

plot(x,y1); xlabel('time'); ylabel('amplitude'); title('f(x)=exp(-|x|)cos(0.5*pi*x)'); grid on diary off

The function of the first signal : y= The function of the second one y= twice the period of the first

cos( cos( where the cosine with

The maximum value of two signals are at t=0 The minimum peak next to the maximum one at t= 0 is at about t=1

Exercise 2
the distance between the maximum peak at t=0 and the minimum peak next to it is larger than the first signal about two times. the distance between the maximum peak at t=0 and the minimum peak next to it is larger than the first signal about two times.

Complex exponentials Download and run compexp.m2 , which includes a 3-D plot of a complex exponential, y (t) , as well as 2-D magnitude/phase and real/imaginary plots. You need 2 2-D plots to have the same information as the 3-D plot. How would you change the script to make the oscillation frequency lower by half? How would you change the script to make the decay faster? Show the TA your plots %compexp.m produces a 3D plot of a decaying complex exponential, % with subplots of magnitude and phase and of real and imaginary % components below it. t = 0:0.01:5; y=3*exp(-(0.25+j*(2*pi))*t); subplot(3,1,1); plot3(t,real(y),imag(y)); grid xlabel('t'),ylabel('Re(y)'),zlabel('Im(y)'); title('3-D plot of a Complex Exponential'); %produce magnitude and phase plots; t vs |y(t)| and t vs. <y(t).

subplot(3,2,3),plot(t,abs(y)),xlabel('t'), ylabel('Magnitude'),title('Magnitude - |y(t)|'); subplot(3,2,4),plot(t,angle(y)),xlabel('t'), ylabel('Angle'),title('Phase - Arg(y(t))'); %produce real and imag plots; t vs |y(t)| and t vs. <y(t). subplot(3,2,5),plot(t,real(y)),xlabel('t'), ylabel('Magnitude'),title('Re(y(t))'); subplot(3,2,6),plot(t,imag(y)),xlabel('t'), ylabel('Angle'),title('Im(y(t))');

function compexp(f,d) %compexp.m produces a 3D plot of a decaying complex exponential, % with subplots of magnitude and phase and of real and imaginary % components below it. if d<0 error('d must be greater than 0') end if f<0 error('Negative frequency')

end figure t = 0:0.01:5; y=3*exp(-(d*0.25+j*(f*2*pi))*t); subplot(3,1,1); plot3(t,real(y),imag(y)); grid xlabel('t'),ylabel('Re(y)'),zlabel('Im(y)'); title('3-D plot of a Complex Exponential'); %produce magnitude and phase plots; t vs |y(t)| and t vs. <y(t). subplot(3,2,3),plot(t,abs(y)),xlabel('t'), ylabel('Magnitude'),title('Magnitude - |y(t)|'); subplot(3,2,4),plot(t,angle(y)),xlabel('t'), ylabel('Angle'),title('Phase - Arg(y(t))'); %produce real and imag plots; t vs |y(t)| and t vs. <y(t). subplot(3,2,5),plot(t,real(y)),xlabel('t'), ylabel('Magnitude'),title('Re(y(t))'); subplot(3,2,6),plot(t,imag(y)),xlabel('t'), ylabel('Angle'),title('Im(y(t))');
.

we can see the second signal decays faster than the first one.

You might also like