This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 EE102 Systems and Signals Fall Quarter 2011 Jin Hyung Lee Matlab Assignment 2 Due: Friday, October 21, 2011 at 5 PM. This laboratory will be concerned with numerically evaluating continuous time convolution integrals. Matlab provides a function conv() that performs a discretetime convolution of two discretetime sequences. We will add a new function to matlab that uses conv() to numerically integrate the continuous time convolution. To do this, well need to learn about how to define new functions in matlab. Matlab provides two ways of executing commands that you have programmed in a file. Both are stored in a .m file or mfile. This first is a script . Invoking the script at the command line causes the file to be treated as terminal input in your current matlab environment. Most of the examples in the book are matlab scripts. Variables created in the script are visible when it completes, and the script has access to all of the variables that have been defined in your work space. Because it can modify your workspace, this is not a good way to implement extentions to matlab. The second option is to define a function in the mfile. In this case, the function operates in its own local context. It doesnt have access to variables in your workspace, only to the function arguments which are are passed by value. Only the returned values are available to the calling function, and these are also passed by value. Hence, function mfiles are a much more robust way to encapsulate repeated operations. As an example, lets say you want to be able to compute the average value of some vector. A function mfile that does this is function a = avg(v) % % Anything you type here is printed when you enter "help avg" % at the matlab prompt. Good things to put here are a description % what the function does, the calling arguments and the % return values....
View Full
Document
 Fall '11
 lee

Click to edit the document details