Laboratory Report

docx

School

Concordia University *

*We aren’t endorsed by this school

Course

342

Subject

Electrical Engineering

Date

Jan 9, 2024

Type

docx

Pages

9

Uploaded by mannybenka

Report
Laboratory Report ELEC 342 Laboratory experiment #3 The Discrete Time Fourier Transform and Introduction to Simulink By Anas Senouci (40132281) Laboratory made on February 23 rd , 2022 Lab section: MJ-X Lab instructor: Mohebbi, Ali Due date: March 7, 2022
OBJECTIVES Part I of this lab will go over some more MATLAB programming language capabilities, such as loops and arrays to implement discrete time Fourier transform of a pulse input. Part II will demonstrate how to use the SIMULINK environment. THEORY The theory behind this lab was mainly to learn how to implement the discrete time Fourier transform on MATLAB with the following formula: TASKS, RESULTS AND DISCUSSION Part I Questions 1: The first question aims to find the Fourier transform of a pulse x[n] over an interval and use the length function to control the number of iterations of the outer loop given in the algorithm used. It important to use the function stem for a discrete signal and the function plot for the transform since it is continuous. The first graph in Figure 1, a rectangular pulse, is similar to Figure 2 in Lab 3 Manual. The second graph showing the DTFT announces a function very similar to a sinc function. Unlike the sinc function, the DTFT of a pulse function is periodic. Questions 2: Question 2 is all about understanding the built-in function of MATLAB used to find the Fourier transform ( fft ). The main goal is to show if the for loop used in question 1 is as precise as the fft function to fid a Fourier transform. The results can be found in the Appendix II, the Figure 2 shows that both ways of finding the Fourier transform lead to the same answer.
Questions 3: The last question of the first part is a bit like the previous question. It refers to the ifft MATLAB function which is used to compute the inverse discrete Fourier transform the concept. The fft function will also be used to compute the input signal x[n] of question 1 and use it as an input for the ifft function. A comparison needs to be made by plotting the original signal x[n] with the signal obtained from the ifft command. The figure 3 shows that the results are similar. Part II Question 1: This question introduces Simulink to simulate the behavior of the equation y[n] = x[n] + (1/4)y[n-1], x[n] being a sine wave. A model is built with Simulink blocks showed in Figure 4. Figure 5 shows a sine wave output by the scope block. CONCLUSION The lab explores the use of the logic and concept of the MATLAB program that are used to find Fourier transform of signals. Several basic functions and commands like the for loop and arrays needed to be used to answer questions. In the second part, Simulink was introduced to show a signal simulation. The scope block shows the output in Figure 5.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
APPENDIX I %Part I Question 1: clear all ; clc; n=-10:10; x=zeros(1,length(n)); x(9:13)=1; subplot(2,1,1); stem(n,x); title 'Rectangular pulse' ; ylabel 'x[n]' ; xlabel 'n' ; w=-pi():pi()/10:pi(); array=-10:10; for i=-10:10 sum=0; for n=-10:10 sum=sum+x(n+11)*exp(-j*w(i+11)*n); end array(i+11)=sum; end magnitude=abs(array); subplot(2,1,2); plot(w,magnitude); title 'DTFT using For loop' ; ylabel( 'X(w)' ); xlabel( 'w' );
Figure 1. Part I Q1 APPENDIX II %Part I Question 2: clear all ; clc; n=-10:10; x=zeros(1,length(n)); x(9:13)=1; subplot(3,1,1); stem(n,x); title 'Rectangular pulse' ; ylabel 'x[n]' ; xlabel 'n' ; w=0:2*pi()/length(n):2*pi()-pi()/length(n); array=0:20;
for i=1:21 sum=0; for n=1:21 sum=sum+x(n)*exp(-j*w(i)*n); end array(i)=sum; end magnitude=abs(array); x_fft=fft(x); w=0:2*pi()/21:2*pi()-pi()/21; magnitude2=abs(x_fft); subplot(3,1,2); plot(w,magnitude2); ylabel( 'X(w)' ); xlabel( 'w' ); title 'DTFT using fft MATLAB function' ; for i=-10:10 sum=0; for n=-10:10 sum=sum+x(n+11)*exp(-j*w(i+11)*n); end array(i+11)=sum; end magnitude=abs(array); subplot(3,1,3); plot(w,magnitude); title 'DTFT using For loop' ; ylabel( 'X(w)' ); xlabel( 'w' );
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Figure 2. Part I Q2 APPENDIX III %Part I Question 3: clear all ; clc; n=-10:10; x=zeros(1,length(n)); x(9:13)=1; subplot(2,1,1); stem(n,x); title 'Rectangular pulse' ; ylabel 'x[n]' ; xlabel 'n' ; x_fft=fft(x); x_ifft=ifft(x_fft); subplot(2,1,2);
stem(n,x_ifft); title 'Rectangular pulse using inverse Fourier Transform function of MATLAB' ; ylabel 'x[n]' ; xlabel 'n' ; Figure 3. Part I Q3 APPENDIX IV
Figure 4. Part II Q1 Figure 5. Part II Q1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help