20115ee102_1_hw3_matlab - 1 EE102 Systems and Signals Fall...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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 discrete-time convolution of two discrete-time 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 m-file. 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 m-file. 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 m-files 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 m-file 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

Page1 / 6

20115ee102_1_hw3_matlab - 1 EE102 Systems and Signals Fall...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online