Presentation is loading. Please wait.

Presentation is loading. Please wait.

ENEE222 Elements of Discrete Signal Analysis Lab 11 1.

Similar presentations


Presentation on theme: "ENEE222 Elements of Discrete Signal Analysis Lab 11 1."— Presentation transcript:

1 ENEE222 Elements of Discrete Signal Analysis Lab 11 1

2 Prepare your working environment
Download the script for lab 11 from ELMS or: terpconnect.umd.edu/~rssaketh/ene222/lab Move files to your desktop Double click the MATLAB icon on the desktop In MATLAB, set “Current Folder” to your desktop Double click the file “lab_11_script.zip” inside MATLAB 2

3 Items 1&2: Anonymous Functions
Single-line command Created on the fly Can be used for the remainder of the session, but cannot be saved as a function M-file Rather recent, and powerful feature of Matlab. Example: fun1 (x,y) cos(1/x+y) Function Name Function Name Operator Used to Construct a Function Handle List of Input Arguments Body of the Function 3

4 Items 3&4: Function Handles
The function handle has the following two properties: Directly invokable: fun1(-0.5) Can be an input argument to anther function: max2(fun1) A function handle of a built-in / user-defined function can be obtained with the help of operator, e.g., myCosine 4

5 Item 5: Meshgrid We have seen how z = f(x,y)=x+2y can be evaluated over a rectangular grid (e.g., with axes x=1:10 and y=1:10 ) using FOR loops. This can also be done without FOR loops using MESHGRID, which generates two matrices with the x- and y-coordinates of the grid points. For example, x=[-1:1:3]; y=[0:0.2:1]; [X,Y]=meshgrid(x,y); X varies horizontally only, and Y varies vertically only. X and Y can be used as arguments in any array-friendly function. (cos, exp, .* ) 5

6 Item 5: Linspace We are familiar with the following syntax:
t = lbound : stepsize : ubound For example, to generate 11 elements between 0 and 1, we can use: t=0:0.1:1 Alternatively, we may use LINSPACE: t = linspace(lbound,ubound,#points) The same result as above is obtained by t = linspace(0,1,11) 6

7 Item 6: Contour A contour plot consists of a number of lines on the x-y plane over which a function z = f(x,y) takes constant value; it thus depicts the variation of a function in discrete terms. contour(Z) % axes labeled by indices contour(X,Y,Z) % actual coordinates “Matrix” axis mode (axis ij) is default for imshow “Cartesian” axis mode (axis xy) is default for contour 7

8 Item 7: 3-D Plotting MESH: 3-D wire-frame surface
SHADING FLAT: remove mesh lines SURF: 3-D surface, basically a filled mesh SURFC: adds a 2-D contour plot on the x-y plane VIEW(AZIMUTH, ELEVATION) The two arguments represent (respectively) horizontal and vertical rotations of an observer facing the origin from an initial position in the far negative y-direction. Both are quoted in degrees. 8


Download ppt "ENEE222 Elements of Discrete Signal Analysis Lab 11 1."

Similar presentations


Ads by Google