Matlab Discrete Time Lab 2
Matlab Discrete Time Lab 2
Exercise No. 2: MATLAB Discrete-Time Signal 2 Objectives: In this Exercise you will learn to: 1. Create MATLAB functions of signals 2. Create MATLAB functions of signal manipulations 3. Apply the created MATLAB functions to perform DiscreteTime Signal Processing. Signal Addition 1. Copy the commands in Figure 5. You may omit the comment to shorten the typing process. 2. Save the function to your created folder in the document file and name the function as sigadd. 3. Close the Editor Window. 4. From the command window, the current directory must be the folder name you created. 5. The following signals will be used for signal addition.
x1 (n) ={2,2,2,0,1,2,3,4} x2 ( n) ={1,0,1,2,3,4,4,4,4,4}
&
6. Copy the following command to represent the signal x1(n) in MATLAB: n1=[-3:4]; x1=[2 2 2 0 1 2 3 4]; [n1;x1] % to view table of x1 wrt time n1
7. Now, create command for signal x2(n). Note: Use n2 for the time variable of x2(n).
Type the following command: [y1, ny1]=sigadd(x1,n1,x2,n2); 9. Write the answer in the space provided.
Signal Multiplication 10. Click New button, then copy the commands in Figure 6. Save it as sigmult. 11. Using the value of x1(n) and x2(n), the following command can be used to multiply the two signals: [y2, ny2]=sigmult(x1,n1,x2,n2); 12. Write the answer in the space provided.
Amplitude Scaling
13. If were going to implement the equation: 3 x1 ( n)
15. Write the command for this equation. Clue: use amplitude scaling for negative amplitude.
y 4 ( n) = x1 ( n) x2 (n)
17. Lets practice signal addition, multiplication and amplitude scaling. Below are the functional representations of the two inputs.
18. Write below the commands for representing the two inputs and their time n. Note: Use n3 for the time variable of input x3 and n4 for the time variable of input x4.
y6 (n) = x3 ( n) * x4 ( n) + 2 x2 (n)