Exercise No. 1: MATLAB Discrete-Time Signal Objectives:: Unit Sample Sequence
Exercise No. 1: MATLAB Discrete-Time Signal Objectives:: Unit Sample Sequence
Exercise No. 1: MATLAB Discrete-Time Signal 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. Creating MATLAB Functions of Signals 1. Create a folder at document file, name it ECE4sectionSURNAMEfirstname. 2. Open MATLAB and click the New button to go the Editor/Debugger Window. Unit Sample Sequence 3. Copy the commands in Figure 1 from your lecture. 4. Save the function to your created folder in the document file and name the function as sampseq. 5. Close the Editor Window. 6. From the command window, the current directory must be the folder name you created. 7. Now we are ready to test the function you created. The equation of unit sample sequence will be represented in MATLAB:
1 n = 0 ( n) = 0 n 0
The time n will be from 5 to 5 since MATLAB can only perform finite duration. 8. Copy the following command to represent the Unit Sample sequence in MATLAB: n0=0; n1=-5; n2=5; x = sampseq(n0, n1, n2) 9. Write the answer in the space provided.
10. Next, lets try this equation: (n 2) . The Unit sample sequence is delayed by 2
samples in time. To do this, copy the following command: n0=2; n1=-5; n2=5; x = sampseq(n0, n1, n2) 11. Write the answer in the space provided.
12. Now Create a command that will perform the equation: (n + 3) for time n from 7 to 3.
Unit Step Sequence 13. Click New button, then copy the comm0ands in Figure 2. Save it as ustep. 14. To perform the Unit Step sequence equation for time n from 5 to 5:
1 n 0 u ( n) = 0 n < 0
16. If were going to delay the unit step sequence by 3 samples in time, the equation will be
u (n 3)
u2 = ustep(3, -3, 7) 17. Write below the answer for this command.
18. Now Create a command that will perform the equation: u (n + 3) for time n from 7 to 7.
Time Shifting. 19. Click New button, then copy the commands in Figure 3. Save it as tshift. 20. Using the given signal:
x( n) ={ 1, 2, 3, 4, 4, 4, 4, 4}
sample in time. To do this, copy the following command: n = [-3:4]; x = [1, 2, 3, 4, 4, 4, 4, 4];
[y, ny]=tshift(x,n,3); 21. Write below the answer for this command.
22. If were going to advance the signal x by 2 samples in time, the equation will be
x (n + 2) , the command will be as follows:
Folding or Reflection. 24. Click New button, then copy the commands in Figure 4. Save it as fold. 25. Using the signal in #20, x(n) will be folded. To do this, copy the following command: [y3, ny3]=fold(x,n); 26. Write the answer in the space provided.