Page 71 -
P. 71

3




                             Elementary Functions and Some of Their Uses




                             The purpose of this chapter is to illustrate and build some practice in the use
                             of elementary functions in selected basic electrical engineering problems. We
                             also construct some simple signal functions that you will encounter in future
                             engineering analysis and design problems.
                             NOTE It is essential to review the Supplement at the end of this book in case
                             you want to refresh your memory on the particular elementary functions
                             covered in the different chapter sections.





                             3.1  Function Files

                             To analyze and graph functions using MATLAB, we have to be able to con-
                             struct functions that can be called from within the MATLAB environment. In
                             MATLAB, functions are made and stored in function M-files. We already used
                             one kind of M-file (script file) to store various executable commands in a rou-
                             tine. Function M-files differ from script M-files in that they have designated
                             input(s) and output(s).
                              The following is an example of a function. Type and save the following
                             function in a file named aline.m:

                                function y=aline(x)
                                % (x,y) is a point on a line that has slope 3
                                % and y-intercept -5
                                y=3*x-5;

                             NOTES
                                1. The word function at the beginning of the file makes it a function
                                   rather than a script file.
                                2. The function name, aline, that appears in the first line of this file
                                   should match the name that we assign to this file name when saving
                                   it (i.e., aline.m).

                              Having created a function M-file in your user volume, move to the com-
                             mand window to learn how to call this function. There are two basic ways to
                             use a function file:
                             0-8493-????-?/00/$0.00+$.50
                             © 2000 by CRC Press LLC
                            © 2001 by CRC Press LLC
   66   67   68   69   70   71   72   73   74   75   76