Version 1.2 Page 1 of 4 Your Name ECE 202 – Lab 3 Advanced MATLAB Date Completed PRELAB 1. Using the MATLAB help command, give the syntax for each of the following commands and describe what they do: a) abs b) addpath c) angle d) axis e) butter f) clf g) conj h) find i) fprintf j) freqs k) freqz l) imag m) length n) ones o) phase p) rand q) real r) size s) zeros 2. Find, either on the internet or one of the networks drives, a WAV(.wav) file between 2 k and 5 k bytes long. Save this file to a directory on your hard drive (N:\) or to a floppy disk. PROGRAMMING 3. Briefly explain what the example script file does. Be specific when describing how the commands work. 4. Using the example of the heavside function, write a function that determines the unit impulse values. © 2001 Department of Electrical and Computer Engineering at Portland State University. Version 1.2 Page 2 of 4 COMPLEX NUMBERS Given the declarations »x = 2 + 2i; »y = 1 + 13j; »z = 7 + i * 5; answer the following questions: 5. What are the commands to determine the real and imaginary parts of x, y, and z? 6. What are the commands to determine the magnitude and phase angle of x, y, and z? 7. What is the complex conjugate of x + y + z? PLOTTING Given the declarations » x = 1:10000; » num = [-4000 0]; » den = [1 2000 100]; » y = freqs(num,den,x); » h = abs(y); create the following plots: 8. Divide the figure window into 2 plots wide and 2 plots deep (2 x 2). 9. In the top left plot, plot x vs h with decimal scales. 10. In the top right plot, plot x vs h using a logarithmic scale for the abscissa. 11. In the lower left plot, plot x vs h using a logarithmic scale for the ordinate. 12. In the lower right corner, plot x vs h using logarithmic scales for both the abscissa and the ordinate. 13. Adjust the ordinate on plots 1 and 2 so that the minimum and maximum are 0 and 2.1 respectively. 14. Paste the plots below. Given the declarations » t = 0:0.1:6 * pi; » y = sin(t); create the following plots: 15. Divide the figure window into a 3 x 1 matrix of plots. 16. In the first plot, use the STEM command to plot y vs t. Terminate each stem with a dot(.). Adjust the axis so that the minimum and maximum values of the abscissa are 0 © 2001 Department of Electrical and Computer Engineering at Portland State University. Version 1.2 Page 3 of 4 and 6 respectively, and the minimum and maximum values of the ordinate are –1 and 1 respectively. 17. In the second plot, use the BAR command to graph y vs t. Adjust the axis so that the minimum and maximum values of the abscissa are 0 and 6 respectively, and the minimum and maximum values of the ordinate are –1 and 1 respectively. 18. In the third plot, use the STAIRS command to plot y vs t. Adjust the axis so that the minimum and maximum values of the abscissa are 0 and 6 respectively, and the minimum and maximum values of the ordinate are –1 and 1 respectively. 19. Paste the plots below. Given the declarations » t = 0:0.1:6 * pi; » y = cos(t); perform the following procedures: 20. Plot t vs y. 21. Using the Edit Axes Properties dialog box, title and label the plot. 22. Change the maximum limit for the abscissa to 18.8 (6). 23. Change the minimum and maximum values for the ordinate to –1.5 and 1.5 respectively. 24. Change the tick step on the abscissa to 1 and the ordinate to 0.5. 25. Turn on the gridlines for the ordinate 26. Using the Edit Line Properties dialog box, change the line width to 2, the marker size to 10, and the marker to diamond. 27. Change the line to a color that is not a valid color for the PLOT command. 28. Using the Edit Text Dialog Box, change the font style and size of the plot title, abscissa label and the ordinate label. Choose any font and size you want but do not use the same font for all three. 29. Paste the plot below. AUDIO TOOLS Given the declarations » t = 0:0.001:5; » y = sin(100 * pi * t); answer the following questions: 30. Describe the difference, if any, between the sounds from the commands sound(y) and soundsc(y). © 2001 Department of Electrical and Computer Engineering at Portland State University. Version 1.2 Page 4 of 4 31. Describe the difference between the sounds produced by sound(y*200) and soundsc(y*200). 32. Describe the difference between the sounds produced by soundsc(y*200,5000) and soundsc(y*200,2500). 33. Describe the difference between the sounds produced by soundsc(y*200,5000) and soundsc(y*200,10000). © 2001 Department of Electrical and Computer Engineering at Portland State University.